<html>
<head><meta charset="utf-8"><title>impl trait · wg-traits · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/index.html">wg-traits</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html">impl trait</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="186200655"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/186200655" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#186200655">(Jan 21 2020 at 16:35)</a>:</h4>
<p>So I'm confused as to what Impl Trait will look like in the chalk ast. I was first assuming that we'd have some item <code>type Foo = impl A + B + C;</code>, but now I see some old tests that have goals like <code>impl Clone: Clone</code></p>



<a name="186202142"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/186202142" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#186202142">(Jan 21 2020 at 16:49)</a>:</h4>
<p>So I'm not <em>100%</em> sure all those tests still apply (though I assume they would)</p>



<a name="186202173"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/186202173" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#186202173">(Jan 21 2020 at 16:50)</a>:</h4>
<p>But, I also am not super sure either</p>



<a name="186203475"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/186203475" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#186203475">(Jan 21 2020 at 17:01)</a>:</h4>
<p>since the new <code>impl Trait</code> does need some def, I would guess the tests need to be rewritten to accomodate that. with the old implementation, one could simply write <code>impl Trait</code> as a type, but presumably now it'll need to be extracted to a definition</p>



<a name="186206525"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/186206525" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#186206525">(Jan 21 2020 at 17:31)</a>:</h4>
<p>I mean, if you can't write <code>impl Trait</code> as a type, then how do you lower <code>fn() -&gt; impl Trait</code>? For <code>type Foo = impl Trait</code>, it makes sense that <code>Foo</code> is an alias to the <code>impl Trait</code> type, to me.</p>



<a name="186206974"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/186206974" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#186206974">(Jan 21 2020 at 17:36)</a>:</h4>
<p>types don't have IDs though, right? so I think during lowering, the <code>impl Trait</code> type needs to be assigned an ID (and then lowered to an alias)</p>



<a name="186207065"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/186207065" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#186207065">(Jan 21 2020 at 17:37)</a>:</h4>
<p>and it can't just be the def ID of the <code>type</code> definition, since you can also have things like <code>fn foo(x: Vec&lt;impl Trait&gt;)</code> (IIRC)</p>



<a name="186207074"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/186207074" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#186207074">(Jan 21 2020 at 17:37)</a>:</h4>
<p>Well, you could use placeholders types</p>



<a name="186207169"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/186207169" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#186207169">(Jan 21 2020 at 17:38)</a>:</h4>
<blockquote>
<p>and it can't just be the def ID of the <code>type</code> definition, since you can also have things like <code>fn foo(x: Vec&lt;impl Trait&gt;)</code> (IIRC)</p>
</blockquote>
<p>Ah, good point. I was thinking of just the result type and parameter indices, but you can also nest them, so it's difficult to have them be a DefId and some offset</p>



<a name="186207246"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/186207246" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#186207246">(Jan 21 2020 at 17:39)</a>:</h4>
<p>but I don't know if you need that whole complexity for the test harness, so it might be enough to only allow explicit <code>type Foo = impl Trait</code> definitions</p>



<a name="186207326"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/186207326" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#186207326">(Jan 21 2020 at 17:40)</a>:</h4>
<p>I mean, you can rewrite everything to that form for tests, I think</p>



<a name="186207347"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/186207347" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#186207347">(Jan 21 2020 at 17:40)</a>:</h4>
<p>Right, that's what I have now in my PR</p>



<a name="186207365"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/186207365" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#186207365">(Jan 21 2020 at 17:40)</a>:</h4>
<p>And you could rewrite the goals to use those types, so you wouldn't need any <code>impl ...</code> in the goals</p>



<a name="186207491"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/186207491" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#186207491">(Jan 21 2020 at 17:42)</a>:</h4>
<p><span class="user-mention" data-user-id="232957">@Jack Huey</span> Could you explain how the goals in those tests work? I'm not sure what to make of this, for example:</p>
<div class="codehilite"><pre><span></span>impl Foo&lt;Ref&lt;&#39;static&gt;&gt;: Foo&lt;Ref&lt;&#39;a&gt;&gt;
</pre></div>



<a name="186208294"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/186208294" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#186208294">(Jan 21 2020 at 17:50)</a>:</h4>
<p><span class="user-mention" data-user-id="125131">@detrumi</span> I actually have no idea tbh</p>



<a name="186208315"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/186208315" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#186208315">(Jan 21 2020 at 17:50)</a>:</h4>
<p>I never really looked at <code>Opaque</code> types</p>



<a name="186208357"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/186208357" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#186208357">(Jan 21 2020 at 17:50)</a>:</h4>
<p>Heh, ok</p>



<a name="186208511"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/186208511" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#186208511">(Jan 21 2020 at 17:52)</a>:</h4>
<p>I can look at it a bit more later today and I'll leave some comments here</p>



<a name="186208587"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/186208587" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#186208587">(Jan 21 2020 at 17:52)</a>:</h4>
<p>Appreciated <span aria-label="slight smile" class="emoji emoji-1f642" role="img" title="slight smile">:slight_smile:</span></p>



<a name="186208591"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/186208591" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#186208591">(Jan 21 2020 at 17:52)</a>:</h4>
<p>I mean, I think theoretically you could write the tests so that they're <code>type Foo = impl Trait; Foo: Trait</code></p>



<a name="186208637"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/186208637" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#186208637">(Jan 21 2020 at 17:53)</a>:</h4>
<p>also, might be worth taking a looking at the rust-analyzer <code>impl Trait</code>-related tests</p>



<a name="186208840"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/186208840" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#186208840">(Jan 21 2020 at 17:55)</a>:</h4>
<p>Yeah, and when this PR gets far enough, connecting it with rust-analyzer should be a great way to test it</p>



<a name="186222895"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/186222895" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#186222895">(Jan 21 2020 at 20:20)</a>:</h4>
<p>Alright, got something down for program clauses. Though I'm wondering which rule is better for the auto traits for <code>type Foo = impl A + B</code>:</p>
<div class="codehilite"><pre><span></span>Implemented(Foo: Send) :- Implemented(A + B: Send) // (1)
Implemented(Foo: Send) :- Implemented(A: Send), Implemented(B: Send) // (2)
</pre></div>


<p>Or maybe it doesn't really matter <span aria-label="shrug" class="emoji emoji-1f937" role="img" title="shrug">:shrug:</span></p>



<a name="186253389"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/186253389" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#186253389">(Jan 22 2020 at 03:51)</a>:</h4>
<p>So, for <code>dyn Trait</code>, order of <code>A</code> and <code>B</code> would matter (according to Niko). But I'm not sure if order matters for <code>impl Trait</code>. but I'm also not sure if switching the clauses in (2) would change anything in Chalk. (Technically, we are "allowed" to select subgoals in any order, though right now they are chosen last first)</p>



<a name="186266369"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/186266369" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#186266369">(Jan 22 2020 at 08:55)</a>:</h4>
<p>Good to know that order might matter in some cases. Let's go with (1) for now, it's easily changed anyways</p>



<a name="187683684"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/187683684" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#187683684">(Feb 07 2020 at 21:51)</a>:</h4>
<blockquote>
<p>So I'm confused as to what Impl Trait will look like in the chalk ast. I was first assuming that we'd have some item <code>type Foo = impl A + B + C;</code>, but now I see some old tests that have goals like <code>impl Clone: Clone</code></p>
</blockquote>
<p>btw I don't think these tests really apply</p>



<a name="187683691"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/187683691" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#187683691">(Feb 07 2020 at 21:51)</a>:</h4>
<p>I think they were thinking about things wrong</p>



<a name="187683756"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/187683756" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#187683756">(Feb 07 2020 at 21:52)</a>:</h4>
<p>I'm not 100% sure what we want for the chalk AST, but it <em>might</em> be something like</p>



<a name="187683763"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/187683763" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#187683763">(Feb 07 2020 at 21:52)</a>:</h4>
<p><code>opaque type Foo: Bounds = Ty;</code></p>



<a name="187683778"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/187683778" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#187683778">(Feb 07 2020 at 21:52)</a>:</h4>
<p>this is obviously not Rust syntax</p>



<a name="187683793"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/187683793" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#187683793">(Feb 07 2020 at 21:52)</a>:</h4>
<p>Having some consistent starting point would be a great help <span aria-label="slight smile" class="emoji emoji-1f642" role="img" title="slight smile">:slight_smile:</span></p>



<a name="187683796"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/187683796" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#187683796">(Feb 07 2020 at 21:53)</a>:</h4>
<p>it depends a bit on what we model <em>in</em> chalk -- I think that to start, I would say that the code which has the job of figuring out the "hidden type" is not chalk's job</p>



<a name="187683809"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/187683809" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#187683809">(Feb 07 2020 at 21:53)</a>:</h4>
<p>we could change that later, but it seems like a good starting point to me</p>



<a name="187683823"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/187683823" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#187683823">(Feb 07 2020 at 21:53)</a>:</h4>
<p>I guess that won't necessatrily help rust-analyzer, but in a way it won't matter</p>



<a name="187683828"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/187683828" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#187683828">(Feb 07 2020 at 21:53)</a>:</h4>
<p>maybe we make the "hidden type" optional</p>



<a name="187683847"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/187683847" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#187683847">(Feb 07 2020 at 21:53)</a>:</h4>
<blockquote>
<p>I guess that won't necessatrily help rust-analyzer, but in a way it won't matter</p>
</blockquote>
<p>to clarify here</p>



<a name="187683919"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/187683919" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#187683919">(Feb 07 2020 at 21:54)</a>:</h4>
<p>the idea is that, if we are "Reveal" mode, then the hidden type becomes "visible" (i.e., we can normalize that alias to the hidden type)</p>



<a name="187683921"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/187683921" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#187683921">(Feb 07 2020 at 21:54)</a>:</h4>
<p>but rust-analyzer would never be in that mode</p>



<a name="187683929"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/187683929" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#187683929">(Feb 07 2020 at 21:54)</a>:</h4>
<p>still, the hidden type is relevant for auto trait "leakage"</p>



<a name="187683939"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/187683939" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#187683939">(Feb 07 2020 at 21:54)</a>:</h4>
<p>which is partly why I say we should just start out by having the AST tell us what it is</p>



<a name="187684012"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/187684012" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#187684012">(Feb 07 2020 at 21:55)</a>:</h4>
<blockquote>
<p><code>opaque type Foo: Bounds = Ty;</code></p>
</blockquote>
<p>Hmm, is <code>Foo</code> the placeholder, and <code>Ty</code> the 'instance' here?</p>



<a name="187684137"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/187684137" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#187684137">(Feb 07 2020 at 21:57)</a>:</h4>
<p>I'm not sure about the term <em>instance</em></p>



<a name="187684145"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/187684145" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#187684145">(Feb 07 2020 at 21:57)</a>:</h4>
<p>but if the idea is</p>



<a name="187684149"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/187684149" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#187684149">(Feb 07 2020 at 21:57)</a>:</h4>
<p>you can define an alias type <code>A</code></p>



<a name="187684208"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/187684208" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#187684208">(Feb 07 2020 at 21:58)</a>:</h4>
<p>every alias type has a <em>placeholder form</em></p>



<a name="187684219"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/187684219" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#187684219">(Feb 07 2020 at 21:58)</a>:</h4>
<p>as well as rules for how to <em>normalize</em> it to some other type</p>



<a name="187684236"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/187684236" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#187684236">(Feb 07 2020 at 21:58)</a>:</h4>
<p>in the placeholder form, you don't know what <code>A</code> represents, but you can still say things about it</p>



<a name="187684246"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/187684246" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#187684246">(Feb 07 2020 at 21:58)</a>:</h4>
<p>so here, <code>Foo</code> would be the alias</p>



<a name="187684253"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/187684253" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#187684253">(Feb 07 2020 at 21:58)</a>:</h4>
<p>and there would indeed be a placeholder form of it</p>



<a name="187684264"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/187684264" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#187684264">(Feb 07 2020 at 21:59)</a>:</h4>
<p>we'd also have rules to normalize <code>Foo</code> to <code>Ty</code> (but they would require <code>Reveal</code> mode)</p>



<a name="187684278"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/187684278" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#187684278">(Feb 07 2020 at 21:59)</a>:</h4>
<p>and we'd have rules for proving that the placeholder version of <code>Foo</code> is <code>Send</code></p>



<a name="187684280"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/187684280" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#187684280">(Feb 07 2020 at 21:59)</a>:</h4>
<p>i.e.,</p>



<a name="187684288"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/187684288" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#187684288">(Feb 07 2020 at 21:59)</a>:</h4>
<div class="codehilite"><pre><span></span>Implemented(PlaceholderFoo: Send) :- Implemented(Ty: Send)
</pre></div>



<a name="189063511"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/189063511" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#189063511">(Feb 25 2020 at 21:33)</a>:</h4>
<p>is this a good topic to use, <span class="user-mention" data-user-id="125131">@detrumi</span> ?</p>



<a name="189063592"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/189063592" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#189063592">(Feb 25 2020 at 21:34)</a>:</h4>
<p>I think the normalization rules for opaque types look like</p>
<div class="codehilite"><pre><span></span>ProjectionEq(T = Ty) :- Reveal
</pre></div>


<p>and</p>
<div class="codehilite"><pre><span></span>ProjectionEq(T = !T)
</pre></div>



<a name="189063605"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/189063605" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#189063605">(Feb 25 2020 at 21:34)</a>:</h4>
<p>where <code>Reveal</code> is a special goal that we never generate program clauses for, but which can be added to the environment at monomrphization time</p>



<a name="189063609"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/189063609" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#189063609">(Feb 25 2020 at 21:34)</a>:</h4>
<p>maybe we have it already? I forget</p>



<a name="189063637"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/189063637" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#189063637">(Feb 25 2020 at 21:35)</a>:</h4>
<p>Huh, interesting. Didn't expect for the reveal concept to show up that literally</p>



<a name="189063940"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/189063940" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#189063940">(Feb 25 2020 at 21:38)</a>:</h4>
<p>we would integrate opaque types into type unification the same way as associated types, I think</p>



<a name="189063954"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/189063954" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#189063954">(Feb 25 2020 at 21:38)</a>:</h4>
<p>i.e., when you try to unify them, we'll generate a subgoal to solve <code>ProjectionEq</code></p>



<a name="189064047"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/189064047" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#189064047">(Feb 25 2020 at 21:40)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116009">nikomatsakis</span> <a href="#narrow/stream/144729-wg-traits/topic/impl.20trait/near/189063954" title="#narrow/stream/144729-wg-traits/topic/impl.20trait/near/189063954">said</a>:</p>
<blockquote>
<p>i.e., when you try to unify them, we'll generate a subgoal to solve <code>ProjectionEq</code></p>
</blockquote>
<p>And it should be called <code>AliasEq</code> to allow all 3 alias kinds, right?</p>



<a name="189064102"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/189064102" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#189064102">(Feb 25 2020 at 21:40)</a>:</h4>
<p>er, yes</p>



<a name="189064103"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/189064103" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#189064103">(Feb 25 2020 at 21:40)</a>:</h4>
<p>sorry</p>



<a name="189064108"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/189064108" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#189064108">(Feb 25 2020 at 21:40)</a>:</h4>
<p>old habits die hard</p>



<a name="189065282"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/189065282" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#189065282">(Feb 25 2020 at 21:53)</a>:</h4>
<p>No worries, just wanted to make sure I understood correctly</p>



<a name="189065548"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/189065548" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#189065548">(Feb 25 2020 at 21:56)</a>:</h4>
<p>does that make sense so far, <span class="user-mention" data-user-id="125131">@detrumi</span> ?</p>



<a name="189065721"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/189065721" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#189065721">(Feb 25 2020 at 21:58)</a>:</h4>
<p>Mostly, yes. Will have to read more into monomorphization</p>



<a name="189065912"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/189065912" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#189065912">(Feb 25 2020 at 22:00)</a>:</h4>
<p>note that in rustc the reveal concept is part of the environment too:</p>



<a name="189065923"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/189065923" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#189065923">(Feb 25 2020 at 22:00)</a>:</h4>
<ul>
<li><a href="https://doc.rust-lang.org/nightly/nightly-rustc/rustc/traits/enum.Reveal.html" target="_blank" title="https://doc.rust-lang.org/nightly/nightly-rustc/rustc/traits/enum.Reveal.html">https://doc.rust-lang.org/nightly/nightly-rustc/rustc/traits/enum.Reveal.html</a></li>
<li><a href="https://doc.rust-lang.org/nightly/nightly-rustc/rustc/ty/struct.ParamEnv.html#structfield.reveal" target="_blank" title="https://doc.rust-lang.org/nightly/nightly-rustc/rustc/ty/struct.ParamEnv.html#structfield.reveal">https://doc.rust-lang.org/nightly/nightly-rustc/rustc/ty/struct.ParamEnv.html#structfield.reveal</a></li>
</ul>



<a name="189065965"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/189065965" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#189065965">(Feb 25 2020 at 22:01)</a>:</h4>
<p>Ah, that's very helpful</p>



<a name="189066172"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/189066172" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#189066172">(Feb 25 2020 at 22:04)</a>:</h4>
<p>I'll try to make time to try out this idea before Friday, so that I can ask some questions then</p>



<a name="189133993"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/189133993" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#189133993">(Feb 26 2020 at 17:04)</a>:</h4>
<p><span class="user-mention" data-user-id="125131">@detrumi</span> is there a open chalk issue for this?</p>



<a name="189133999"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/189133999" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#189133999">(Feb 26 2020 at 17:04)</a>:</h4>
<p>no, right?</p>



<a name="189134021"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/189134021" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#189134021">(Feb 26 2020 at 17:05)</a>:</h4>
<p>/me goes to create one</p>



<a name="189134229"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/189134229" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#189134229">(Feb 26 2020 at 17:07)</a>:</h4>
<p>should probably bring back the "current sprint" label and add it, in addition to the &amp;self to Interner</p>



<a name="189134305"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/189134305" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#189134305">(Feb 26 2020 at 17:08)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116009">nikomatsakis</span> <a href="#narrow/stream/144729-wg-traits/topic/impl.20trait/near/189133999" title="#narrow/stream/144729-wg-traits/topic/impl.20trait/near/189133999">said</a>:</p>
<blockquote>
<p>no, right?</p>
</blockquote>
<p>correct</p>



<a name="189134411"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/189134411" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#189134411">(Feb 26 2020 at 17:09)</a>:</h4>
<p>created <a href="https://github.com/rust-lang/chalk/issues/335" target="_blank" title="https://github.com/rust-lang/chalk/issues/335">https://github.com/rust-lang/chalk/issues/335</a></p>



<a name="189134426"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/189134426" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#189134426">(Feb 26 2020 at 17:09)</a>:</h4>
<p>we can update the description as we go to make it make sense</p>



<a name="189134433"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/189134433" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#189134433">(Feb 26 2020 at 17:10)</a>:</h4>
<p>but we should also be documenting this stuff in the chalk book, I think</p>



<a name="189134680"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/189134680" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#189134680">(Feb 26 2020 at 17:11)</a>:</h4>
<p>Yeah, I'll do that in a separate PR at some point</p>



<a name="189246635"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/189246635" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#189246635">(Feb 27 2020 at 19:16)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> I added the <code>Reveal</code> goal. Not sure yet where to add <code>Reveal</code> to the environment, so I'm doing that in <code>to_program_clauses</code> for now. Somehow I got the test working without the <code>AliasEq(T&lt;..&gt; = !T)</code>, so I might be mixing up <code>!T</code> with the unnormalized <code>T</code></p>



<a name="189247137"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/189247137" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#189247137">(Feb 27 2020 at 19:22)</a>:</h4>
<blockquote>
<p>Not sure yet where to add <code>Reveal</code> to the environment, so I'm doing that in <code>to_program_clauses</code> for now.</p>
</blockquote>
<p>AFAIU, that should be up to the caller. Whether <code>Reveal</code> should be in the environment depends on in what phase rustc is calling the solver</p>



<a name="189247878"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/189247878" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#189247878">(Feb 27 2020 at 19:30)</a>:</h4>
<p>Right. Should it be an item in the <code>chalk-parse</code> AST then?</p>



<a name="189255894"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/189255894" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#189255894">(Feb 27 2020 at 20:55)</a>:</h4>
<p>can't the tests specify the environment? <span aria-label="thinking" class="emoji emoji-1f914" role="img" title="thinking">:thinking:</span></p>



<a name="189258458"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/189258458" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#189258458">(Feb 27 2020 at 21:20)</a>:</h4>
<p>Ah, good point</p>



<a name="189427595"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/189427595" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#189427595">(Mar 01 2020 at 09:57)</a>:</h4>
<p>Actually, the environment is just the list of program clauses, so it should be an item after all</p>



<a name="189506235"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/189506235" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#189506235">(Mar 02 2020 at 16:12)</a>:</h4>
<p><span class="user-mention" data-user-id="125131">@detrumi</span> tests can use the goal <code>if (Reveal) { .. }</code></p>



<a name="189506246"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/189506246" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#189506246">(Mar 02 2020 at 16:12)</a>:</h4>
<p>to add <code>Reveal</code> into the environment</p>



<a name="189520230"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/189520230" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#189520230">(Mar 02 2020 at 18:27)</a>:</h4>
<p>Ah nice, that did the trick</p>



<a name="189524919"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/189524919" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#189524919">(Mar 02 2020 at 19:11)</a>:</h4>
<p>I'm updating the book and might add some more tests, but the PR should be ready for review now</p>



<a name="189531707"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/189531707" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#189531707">(Mar 02 2020 at 20:16)</a>:</h4>
<p><span class="user-mention" data-user-id="125131">@detrumi</span> great!</p>



<a name="189639871"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/189639871" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#189639871">(Mar 03 2020 at 22:07)</a>:</h4>
<p>so... what I'm imagining for return type impl Trait in RA is roughly:</p>
<ul>
<li>we need to give <code>impl Trait</code>s in function return types IDs, which they don't have yet</li>
<li>if Chalk requires the 'revealed' type, I think we'll need to have a query which computes this for a function, by running type inference for that function and unifying the actual return type with the declared return type. It's a bit weird to have to run inference for a function to get its 'full' type, but it seems it's necessary</li>
<li>and then I think it's just a matter of creating an impl Trait type with the right ID and revealed type at the call site?</li>
</ul>



<a name="189640135"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/189640135" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#189640135">(Mar 03 2020 at 22:11)</a>:</h4>
<p>Yeah, so you need the whole function body to infer the actual returned type</p>



<a name="189640226"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/189640226" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#189640226">(Mar 03 2020 at 22:12)</a>:</h4>
<p>Giving <code>impl Trait</code> types a type ID makes sense, given that there'll be more places where impl Trait will be allowed in the future, not just in functions</p>



<a name="189640520"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/189640520" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#189640520">(Mar 03 2020 at 22:16)</a>:</h4>
<p>It should be possible to get at least some info without revealing the type, but for the best results you need to reveal by checking the actual return type</p>



<a name="189640675"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/189640675" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#189640675">(Mar 03 2020 at 22:19)</a>:</h4>
<p>if we don't <em>need</em> to pass it, we could try it without first. We don't really deal a lot with auto traits anyway yet</p>



<a name="189679124"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/189679124" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#189679124">(Mar 04 2020 at 10:49)</a>:</h4>
<p><span class="user-mention" data-user-id="129457">@Florian Diebold</span>  One important thing that's changing in chalk is that <code>AliasTy</code> became an enum, to account for both projections and impl Trait (and later type aliases as well). In chalk there are both AssocTypeId and ImplTraitId types, but they could aloso be the same, like TypeAliasId is in RA</p>



<a name="189679164"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/189679164" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#189679164">(Mar 04 2020 at 10:49)</a>:</h4>
<p><code>TypeAliasId</code> doesn't include impl trait though, it's just any kind of <code>type X = ...</code></p>



<a name="189679174"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/189679174" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#189679174">(Mar 04 2020 at 10:50)</a>:</h4>
<p>but yeah, that shouldn't be a problem</p>



<a name="189679475"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/189679475" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#189679475">(Mar 04 2020 at 10:53)</a>:</h4>
<p>My PR also added an <code>auto_traits</code> method to <code>RustIrDatabase</code>, but I'm not entirely sure if that's the right place</p>



<a name="189685217"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/189685217" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#189685217">(Mar 04 2020 at 12:20)</a>:</h4>
<p>that seems fine</p>



<a name="189691020"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/189691020" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#189691020">(Mar 04 2020 at 13:44)</a>:</h4>
<p>Created a WIP PR for RA that uses the impl trait branch: <a href="https://github.com/rust-analyzer/rust-analyzer/pull/3446" target="_blank" title="https://github.com/rust-analyzer/rust-analyzer/pull/3446">https://github.com/rust-analyzer/rust-analyzer/pull/3446</a></p>



<a name="189740799"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/189740799" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#189740799">(Mar 04 2020 at 22:05)</a>:</h4>
<p>@detrumi I pushed a commit with what I imagine should be the general structure for giving return type impl traits IDs and integrating them with Chalk to your branch, hope you don't mind. This should hopefully make clearer how I think the whole thing should work. If you want to continue this, there are a bunch of todos (otherwise I'll do it once your Chalk PR is merged)</p>



<a name="189742129"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/189742129" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#189742129">(Mar 04 2020 at 22:22)</a>:</h4>
<p>also, some things I noticed:</p>
<ul>
<li>the 'hidden type' for a return type impl trait can depend on the function's type parameter, so I think <code>ty</code> in <code>ImplTraitDatum</code> needs to have <code>Binders</code>?</li>
<li>we can have <code>impl Iterator&lt;Item = Something&gt;</code>, so I don't think the <code>bounds</code> can just be <code>TypeBound</code>s?</li>
</ul>



<a name="189742274"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/189742274" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#189742274">(Mar 04 2020 at 22:24)</a>:</h4>
<p>also, if we have to infer a function to get full info about its RPIT, how do we actually deal with mutual recursion? e.g. <a href="https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=c482c0eb69648e53b91ab137af87dcb7" target="_blank" title="https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=c482c0eb69648e53b91ab137af87dcb7">like this</a>. Maybe I'm misunderstanding how this works after all -- don't we need to infer <code>a</code> to get its revealed return type so we know the auto traits of its RPIT so we can infer <code>b</code> so... ?</p>



<a name="189742293"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/189742293" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#189742293">(Mar 04 2020 at 22:24)</a>:</h4>
<p>(<span class="user-mention" data-user-id="116009">@nikomatsakis</span> see above)</p>



<a name="189744154"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/189744154" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#189744154">(Mar 04 2020 at 22:47)</a>:</h4>
<p>interesting! I was pretty busy today and didn't get a chance to follow up on this</p>



<a name="189766320"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/189766320" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#189766320">(Mar 05 2020 at 07:35)</a>:</h4>
<p><span class="user-mention silent" data-user-id="129457">Florian Diebold</span> <a href="#narrow/stream/144729-wg-traits/topic/impl.20trait/near/189740799" title="#narrow/stream/144729-wg-traits/topic/impl.20trait/near/189740799">said</a>:</p>
<blockquote>
<p>@detrumi I pushed a commit with what I imagine should be the general structure for giving return type impl traits IDs and integrating them with Chalk to your branch, hope you don't mind. This should hopefully make clearer how I think the whole thing should work. If you want to continue this, there are a bunch of todos (otherwise I'll do it once your Chalk PR is merged)</p>
</blockquote>
<p>Great! Yeah, that was exactly what I intended the PR for, to push the discussion forward. And I think the plan was to have impl trait integration work in RA before merging the chalk PR, but we'll see</p>



<a name="189766476"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/189766476" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#189766476">(Mar 05 2020 at 07:40)</a>:</h4>
<p>For the mutual recursion example, both functions are only ever returning <code>&amp;str</code>, right? The example doesn't work if you actually try to return different types</p>



<a name="189766616"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/189766616" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#189766616">(Mar 05 2020 at 07:43)</a>:</h4>
<blockquote>
<p>For the mutual recursion example, both functions are only ever returning &amp;str, right? The example doesn't work if you actually try to return different types</p>
</blockquote>
<p>Yes, but if the return type influences auto traits, we'll still need the return type of a to type-check b and vice versa</p>



<a name="189766802"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/189766802" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#189766802">(Mar 05 2020 at 07:47)</a>:</h4>
<p>ah, when I actually require <code>Send</code> on the types, rustc reports a cycle: <a href="https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=ef998b31e094ba5e1969ecdb4b9ed7c7" target="_blank" title="https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=ef998b31e094ba5e1969ecdb4b9ed7c7">https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=ef998b31e094ba5e1969ecdb4b9ed7c7</a></p>



<a name="189766938"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/189766938" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#189766938">(Mar 05 2020 at 07:50)</a>:</h4>
<p>Interesting how the error message exposes the internal workings, like how it talks about <code>a::{{opaque}}#0</code></p>



<a name="189767285"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/189767285" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#189767285">(Mar 05 2020 at 07:58)</a>:</h4>
<p>but I think it means that we need to somehow only require the revealed type if we actually need some auto trait :/</p>



<a name="189768573"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/189768573" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#189768573">(Mar 05 2020 at 08:21)</a>:</h4>
<p><span class="user-mention silent" data-user-id="129457">Florian Diebold</span> <a href="#narrow/stream/144729-wg-traits/topic/impl.20trait/near/189742129" title="#narrow/stream/144729-wg-traits/topic/impl.20trait/near/189742129">said</a>:</p>
<blockquote>
<p>also, some things I noticed:</p>
<ul>
<li>the 'hidden type' for a return type impl trait can depend on the function's type parameter, so I think <code>ty</code> in <code>ImplTraitDatum</code> needs to have <code>Binders</code>?</li>
<li>we can have <code>impl Iterator&lt;Item = Something&gt;</code>, so I don't think the <code>bounds</code> can just be <code>TypeBound</code>s?</li>
</ul>
</blockquote>
<p>Good points. I'll have to read up a bit about binders and such, but adding binders should be doable. Not sure what bounds should be other than <code>TraitBound</code>, but I'll try to add some tests for this</p>



<a name="189784697"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/189784697" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#189784697">(Mar 05 2020 at 12:21)</a>:</h4>
<blockquote>
<p>Not sure what bounds should be other than TraitBound, but I'll try to add some tests for this</p>
</blockquote>
<p>why not use the same representation as <code>Ty::Dyn</code>(i.e. <code>QuantifiedWhereClause</code>s)?</p>



<a name="189845341"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/189845341" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#189845341">(Mar 05 2020 at 22:43)</a>:</h4>
<p>going to try and catch up on this now :)</p>



<a name="189893382"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/189893382" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#189893382">(Mar 06 2020 at 13:45)</a>:</h4>
<p>ok I failed :) let me try again</p>



<a name="190228585"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190228585" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190228585">(Mar 10 2020 at 21:38)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> I think in principle it's not a problem for RA to do type inference on the function to find the hidden type; but we need to make it so that it's only necessary to do that if we actually need the auto traits. Otherwise we can't handle mutually recursive functions returning impl Trait. rustc allows that, it only reports a cycle if you actually require an auto trait in those mutually recursive functions</p>



<a name="190284020"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190284020" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190284020">(Mar 11 2020 at 14:02)</a>:</h4>
<p><code>ImplTraitDatum</code> now uses <code>Vec&lt;QuantifiedWhereClause&lt;I&gt;&gt;</code> for the bounds, and binders around the type</p>



<a name="190284350"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190284350" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190284350">(Mar 11 2020 at 14:05)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> Could you make some time to review this?</p>



<a name="190285594"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190285594" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190285594">(Mar 11 2020 at 14:16)</a>:</h4>
<p>So, quickly glanced at the tests</p>



<a name="190285608"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190285608" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190285608">(Mar 11 2020 at 14:16)</a>:</h4>
<p>I'm a bit confused</p>



<a name="190285653"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190285653" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190285653">(Mar 11 2020 at 14:16)</a>:</h4>
<p>specifically, the test with params</p>



<a name="190285695"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190285695" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190285695">(Mar 11 2020 at 14:17)</a>:</h4>
<p>If the type is <code>T&lt;U&gt;</code>, then how can you have a goal <code>T: Trait</code>?</p>



<a name="190285739"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190285739" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190285739">(Mar 11 2020 at 14:17)</a>:</h4>
<p>Yeah, I don't think what I did there was correct</p>



<a name="190285752"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190285752" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190285752">(Mar 11 2020 at 14:17)</a>:</h4>
<p>do we not need a <code>exists&lt;U&gt; { T&lt;U&gt;: Trait }</code> or <code>forall&lt;U&gt; { T&lt;U&gt;: Trait }</code></p>



<a name="190285875"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190285875" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190285875">(Mar 11 2020 at 14:18)</a>:</h4>
<p>I haven't really looked at the rest. But if that lowers/passes without a substitution, is something wrong?</p>



<a name="190286129"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190286129" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190286129">(Mar 11 2020 at 14:21)</a>:</h4>
<p>I might just be wrong and you <em>can</em> have a goal <code>T: Trait</code> where <code>T</code> has params (but I'm not sure what it would be lowered into)</p>



<a name="190286177"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190286177" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190286177">(Mar 11 2020 at 14:21)</a>:</h4>
<p>If I wrap it in a exists in the goal (or try <code>T&lt;U&gt;: Trait</code> without the exists even), it gives back a <code>CannotApplyTypeParameter</code> error</p>



<a name="190286238"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190286238" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190286238">(Mar 11 2020 at 14:22)</a>:</h4>
<p>But yeah, it looks wrong</p>



<a name="190286504"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190286504" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190286504">(Mar 11 2020 at 14:24)</a>:</h4>
<p>I'm not familiar at all with the lowering code, so I can't really say what's going on</p>



<a name="190286552"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190286552" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190286552">(Mar 11 2020 at 14:25)</a>:</h4>
<p>Is it "cannot apply type parameter <code>U</code>"?</p>



<a name="190286837"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190286837" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190286837">(Mar 11 2020 at 14:28)</a>:</h4>
<p>The lowering tries to get a <code>StructId</code> <a href="https://github.com/rust-lang/chalk/blob/43fcfef6b2a78bab7e68ad6041f990ba0d3258f4/chalk-integration/src/lowering.rs#L1086" target="_blank" title="https://github.com/rust-lang/chalk/blob/43fcfef6b2a78bab7e68ad6041f990ba0d3258f4/chalk-integration/src/lowering.rs#L1086">here</a></p>



<a name="190287007"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190287007" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190287007">(Mar 11 2020 at 14:29)</a>:</h4>
<p>oh, you know, I bet this goes back to the discussion we had about knowing the <code>Self</code> type</p>



<a name="190287086"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190287086" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190287086">(Mar 11 2020 at 14:30)</a>:</h4>
<p>Probably right now, you can't use params in the type itself</p>



<a name="190287275"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190287275" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190287275">(Mar 11 2020 at 14:32)</a>:</h4>
<p>Hmm, let me just remove that test then. For reference, this somehow passes at the moment:</p>
<div class="codehilite"><pre><span></span>program {
    trait Trait { }
    struct Ty&lt;U&gt; { }
    struct Unit { }
    impl Trait for Ty&lt;Unit&gt; { }

    opaque type T&lt;U&gt;: Trait = Ty&lt;U&gt;;
}

goal {
    if (Reveal) {
        T: Trait
    }
} yields {
    &quot;Unique; substitution []&quot;
}
</pre></div>



<a name="190287355"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190287355" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190287355">(Mar 11 2020 at 14:33)</a>:</h4>
<p>I feel like for the <code>opaque_bounds_with_params</code> test, we <em>should</em> be able to say <code>forall&lt;U&gt; { T&lt;U&gt;: Trait }</code> in both <code>Reveal</code> and <code>!Reveal</code></p>



<a name="190287525"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190287525" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190287525">(Mar 11 2020 at 14:34)</a>:</h4>
<p>But, say, if <code>impl Foo for Ty&lt;Bar&gt;</code>, then we should be able to say <code>if (Reveal) { T&lt;Bar&gt;: Foo }</code></p>



<a name="190287539"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190287539" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190287539">(Mar 11 2020 at 14:34)</a>:</h4>
<p>But I'm not sure about that</p>



<a name="190287757"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190287757" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190287757">(Mar 11 2020 at 14:36)</a>:</h4>
<p>The problem, with the first goal there, is that I think right now we can't have an <em>unknown</em> <code>Self</code> type (or I guess, a <em>known</em> <code>Self</code> with an unknown <code>Substitution</code>?)</p>



<a name="190287837"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190287837" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190287837">(Mar 11 2020 at 14:37)</a>:</h4>
<p>Wait that's not right</p>



<a name="190287857"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190287857" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190287857">(Mar 11 2020 at 14:37)</a>:</h4>
<p>of course we should be about to have bound vars as a param on a type</p>



<a name="190288968"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190288968" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190288968">(Mar 11 2020 at 14:46)</a>:</h4>
<p>Not sure what you mean with that last sentence, but I don't think <code>forall&lt;U&gt; { T&lt;U&gt;: Trait }</code> really works, as it only holds for <code>T&lt;Unit&gt;</code> in the test. So that should be a <code>exists&lt;U&gt;</code> instead</p>



<a name="190289325"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190289325" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190289325">(Mar 11 2020 at 14:48)</a>:</h4>
<p>hmm I think that's kind of a well-formedness thing? like if you have a function returning <code>impl Trait</code>, you can't have your return value only implement the trait in some cases. the hidden type needs to implement the type in all cases, and the <code>T&lt;U&gt;</code> should by definition implement it for all <code>U</code></p>



<a name="190289383"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190289383" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190289383">(Mar 11 2020 at 14:49)</a>:</h4>
<p>keep in mind that the parameters for the opaque type are the type parameters of the function in practice</p>



<a name="190289504"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190289504" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190289504">(Mar 11 2020 at 14:50)</a>:</h4>
<p>it's mostly for unification purposes; the types of two calls to an RPIT function are observably the same exactly if the type parameters to the function are the same (or unify) in both cases</p>



<a name="190289592"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190289592" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190289592">(Mar 11 2020 at 14:51)</a>:</h4>
<p>and so whether the hidden type implements the trait (for all type parameters) is checked at the definition site of the impl trait (i.e. the function definition), and callers can just assume it</p>



<a name="190290179"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190290179" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190290179">(Mar 11 2020 at 14:55)</a>:</h4>
<p><span class="user-mention silent" data-user-id="129457">Florian Diebold</span> <a href="#narrow/stream/144729-wg-traits/topic/impl.20trait/near/190289325" title="#narrow/stream/144729-wg-traits/topic/impl.20trait/near/190289325">said</a>:</p>
<blockquote>
<p>hmm I think that's kind of a well-formedness thing? like if you have a function returning <code>impl Trait</code>, you can't have your return value only implement the trait in some cases. the hidden type needs to implement the type in all cases, and the <code>T&lt;U&gt;</code> should by definition implement it for all <code>U</code></p>
</blockquote>
<p>Right this</p>



<a name="190293707"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190293707" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190293707">(Mar 11 2020 at 15:23)</a>:</h4>
<p><span class="user-mention" data-user-id="129457">@Florian Diebold</span> Slightly unrelated, but it looks like the chalk integration in RA will need some updates, now that <code>cast()</code> takes an interner as argument</p>



<a name="190293843"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190293843" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190293843">(Mar 11 2020 at 15:24)</a>:</h4>
<p>yes, I was kind of waiting for all these changes to be done</p>



<a name="190336235"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190336235" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190336235">(Mar 11 2020 at 21:55)</a>:</h4>
<p><span class="user-mention" data-user-id="125131">@detrumi</span> left an initial round of review comments -- it looks close! Some things I think are not quite right around how the bounders are setup. I'd be game to try and talk about it in more depth, perhaps on Friday (or maybe tomorrow, but THu tends to be quite a full day for me)</p>



<a name="190360059"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190360059" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190360059">(Mar 12 2020 at 06:32)</a>:</h4>
<p>Thanks! Let's discuss this on Friday then</p>



<a name="190903151"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190903151" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190903151">(Mar 17 2020 at 20:00)</a>:</h4>
<p>OK <span class="user-mention" data-user-id="125131">@detrumi</span> well I've been kind of knocked back by COVID-19 and the rest here, and this Friday I'll be off, but what about planning some time to talk about this on Wednesday (tomorrow) -- would 10am US Eastern time maybe be a good fit for you?</p>



<a name="190903809"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190903809" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190903809">(Mar 17 2020 at 20:05)</a>:</h4>
<p>Yes, that works for me</p>



<a name="190980695"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190980695" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190980695">(Mar 18 2020 at 13:40)</a>:</h4>
<p><span class="user-mention" data-user-id="125131">@detrumi</span> I'm around now btw</p>



<a name="190981014"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190981014" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190981014">(Mar 18 2020 at 13:42)</a>:</h4>
<p>Great, so am I</p>



<a name="190981152"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190981152" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190981152">(Mar 18 2020 at 13:43)</a>:</h4>
<p>I guess I should review what I wrote</p>



<a name="190981332"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190981332" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190981332">(Mar 18 2020 at 13:45)</a>:</h4>
<p>Let's start with naming: opaque type vs impl trait</p>



<a name="190981373"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190981373" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190981373">(Mar 18 2020 at 13:45)</a>:</h4>
<p>I called it opaque type around the ast, and impl trait once lowered</p>



<a name="190981475"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190981475" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190981475">(Mar 18 2020 at 13:46)</a>:</h4>
<p>I see</p>



<a name="190981503"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190981503" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190981503">(Mar 18 2020 at 13:46)</a>:</h4>
<p>I might've got the other way</p>



<a name="190981516"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190981516" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190981516">(Mar 18 2020 at 13:46)</a>:</h4>
<p>interestingly, that's exactly the other way around in RA <span aria-label="sweat smile" class="emoji emoji-1f605" role="img" title="sweat smile">:sweat_smile:</span></p>



<a name="190981536"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190981536" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190981536">(Mar 18 2020 at 13:46)</a>:</h4>
<p>in the sense that <code>impl Trait</code> is the "concrete syntax" people use, but the "opaque type" is more the underlying concept</p>



<a name="190981559"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190981559" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190981559">(Mar 18 2020 at 13:47)</a>:</h4>
<p>though now that we adopted the <code>type Foo = impl Trait</code> syntax for declaring an opaque type,</p>



<a name="190981578"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190981578" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190981578">(Mar 18 2020 at 13:47)</a>:</h4>
<p>I feel like we could just say impl Trait everywhere (also in rustc),</p>



<a name="190981593"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190981593" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190981593">(Mar 18 2020 at 13:47)</a>:</h4>
<p>although there is some potential confusion because <code>impl Trait</code> can <em>also</em> be used for other things of course</p>



<a name="190981607"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190981607" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190981607">(Mar 18 2020 at 13:47)</a>:</h4>
<p>e.g., <code>fn foo(x: impl Trait)</code>, which is something else</p>



<a name="190981633"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190981633" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190981633">(Mar 18 2020 at 13:47)</a>:</h4>
<p>The ast syntax is still <code>opaque type T: Trait = Ty;</code> in my PR</p>



<a name="190981640"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190981640" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190981640">(Mar 18 2020 at 13:47)</a>:</h4>
<p>and I think indeed that within rustc we use <code>impl Trait</code> for the "ast type", but when we find it in the "existential" position, we create an "opaque type"</p>



<a name="190981641"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190981641" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190981641">(Mar 18 2020 at 13:47)</a>:</h4>
<p>hence the confusion, I think</p>



<a name="190981653"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190981653" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190981653">(Mar 18 2020 at 13:47)</a>:</h4>
<p>yeah, chalk is a bit different because</p>



<a name="190981687"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190981687" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190981687">(Mar 18 2020 at 13:48)</a>:</h4>
<p>it doesn't really take in true rust syntax</p>



<a name="190981739"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190981739" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190981739">(Mar 18 2020 at 13:48)</a>:</h4>
<p>I say just use opaque type uniformly for now</p>



<a name="190981814"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190981814" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190981814">(Mar 18 2020 at 13:48)</a>:</h4>
<p>which seems consistent with rustc + r-a (if I understood <span class="user-mention" data-user-id="129457">@Florian Diebold</span> correctly)</p>



<a name="190981937"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190981937" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190981937">(Mar 18 2020 at 13:49)</a>:</h4>
<p>So you mean renaming things like ImplTraitDatum to OpaqueTyDatum as well, right?</p>



<a name="190981972"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190981972" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190981972">(Mar 18 2020 at 13:49)</a>:</h4>
<p>I also feel that "opaque type" just works better in written text than "impl trait", I always wonder whether I should write impl Trait or <code>impl Trait</code> or impl Trait type... <span aria-label="sweat smile" class="emoji emoji-1f605" role="img" title="sweat smile">:sweat_smile:</span></p>



<a name="190982121"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190982121" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190982121">(Mar 18 2020 at 13:50)</a>:</h4>
<p><span class="user-mention silent" data-user-id="125131">detrumi</span> <a href="#narrow/stream/144729-wg-traits/topic/impl.20trait/near/190981937" title="#narrow/stream/144729-wg-traits/topic/impl.20trait/near/190981937">said</a>:</p>
<blockquote>
<p>So you mean renaming things like ImplTraitDatum to OpaqueTyDatum as well, right?</p>
</blockquote>
<p>right</p>



<a name="190982208"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190982208" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190982208">(Mar 18 2020 at 13:51)</a>:</h4>
<p>Yeah, I think it's useful to have a name for the "existential impl trait" concept anyway, even if it's not something that appears in rust's concrete syntax, and opaque type is I guess a decent enough name for that</p>



<a name="190982595"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190982595" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190982595">(Mar 18 2020 at 13:54)</a>:</h4>
<p><span class="user-mention" data-user-id="125131">@detrumi</span> ok so apart from the name</p>



<a name="190982623"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190982623" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190982623">(Mar 18 2020 at 13:54)</a>:</h4>
<p>I think there were two other things</p>



<a name="190982657"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190982657" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190982657">(Mar 18 2020 at 13:55)</a>:</h4>
<p>well maybe more than two but at least two :)</p>



<a name="190982670"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190982670" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190982670">(Mar 18 2020 at 13:55)</a>:</h4>
<ul>
<li>making the hidden type a distinct callback, used "on demand"</li>
</ul>



<a name="190982706"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190982706" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190982706">(Mar 18 2020 at 13:55)</a>:</h4>
<ul>
<li>getting the binders correct</li>
</ul>



<a name="190982715"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190982715" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190982715">(Mar 18 2020 at 13:55)</a>:</h4>
<p>of the two, I'm more worried about the 2nd one</p>



<a name="190982722"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190982722" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190982722">(Mar 18 2020 at 13:55)</a>:</h4>
<p>I could see doing the 1st one in a follow-up PR</p>



<a name="190982767"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190982767" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190982767">(Mar 18 2020 at 13:56)</a>:</h4>
<p>Alright, let's focus on the 2nd then</p>



<a name="190982883"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190982883" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190982883">(Mar 18 2020 at 13:56)</a>:</h4>
<p>I'm referring to <a href="https://github.com/rust-lang/chalk/pull/324/files/32223e4b13463070edd5f89b2145c5934228e314#r391285010" target="_blank" title="https://github.com/rust-lang/chalk/pull/324/files/32223e4b13463070edd5f89b2145c5934228e314#r391285010">this comment</a></p>



<a name="190983027"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190983027" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190983027">(Mar 18 2020 at 13:58)</a>:</h4>
<p>but now I'm reading a bit more to make sure what i'm saying makes sense ..</p>



<a name="190983101"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190983101" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190983101">(Mar 18 2020 at 13:58)</a>:</h4>
<p>ok, so, a <code>QuantifiedWhereClause</code> -- that represents a where clause like <code>where T: Foo</code> or (this is the quantified bit) <code>where for&lt;'a&gt; T: Foo&lt;'a&gt;</code></p>



<a name="190983159"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190983159" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190983159">(Mar 18 2020 at 13:58)</a>:</h4>
<p>actually though an opaque type has a bit more stuff going on I realize</p>



<a name="190983261"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190983261" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190983261">(Mar 18 2020 at 13:59)</a>:</h4>
<p>well, first off, there are really both "where clauses" <em>and</em> "bounds", just like with an associated type</p>



<a name="190983272"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190983272" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190983272">(Mar 18 2020 at 13:59)</a>:</h4>
<p>Ah I see, you suggested to put the hidden type inside the binders</p>



<a name="190983358"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190983358" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190983358">(Mar 18 2020 at 14:00)</a>:</h4>
<p>where the "Bounds" are the things that "other code" gets to assume are true about the hidden type</p>



<a name="190983374"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190983374" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190983374">(Mar 18 2020 at 14:00)</a>:</h4>
<p>Yeah, it's quite confusing having both of those at play</p>



<a name="190983380"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190983380" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190983380">(Mar 18 2020 at 14:00)</a>:</h4>
<p>and the "where clauses" are things that the "other code" must prove</p>



<a name="190983421"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190983421" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190983421">(Mar 18 2020 at 14:00)</a>:</h4>
<p>e.g.</p>
<div class="codehilite"><pre><span></span><span class="k">type</span> <span class="nc">Foo</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="w"> </span><span class="k">where</span><span class="w"> </span><span class="n">T</span>: <span class="nc">Hash</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">impl</span><span class="w"> </span><span class="n">Debug</span><span class="p">;</span><span class="w"></span>
</pre></div>



<a name="190983461"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190983461" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190983461">(Mar 18 2020 at 14:01)</a>:</h4>
<p>now, in the WF checking etc, we get to <em>assume</em> <code>T: Hash</code> but we must prove <code>$HIDDEN: Debug</code></p>



<a name="190983510"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190983510" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190983510">(Mar 18 2020 at 14:01)</a>:</h4>
<p>but in the "outside", to write <code>Foo&lt;X&gt;</code> we must <em>prove</em> <code>X: Hash</code> but we get to assume <code>!Foo&lt;X&gt;: Debug</code></p>



<a name="190983600"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190983600" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190983600">(Mar 18 2020 at 14:02)</a>:</h4>
<p><span class="user-mention silent" data-user-id="125131">detrumi</span> <a href="#narrow/stream/144729-wg-traits/topic/impl.20trait/near/190983272" title="#narrow/stream/144729-wg-traits/topic/impl.20trait/near/190983272">said</a>:</p>
<blockquote>
<p>Ah I see, you suggested to put the hidden type inside the binders</p>
</blockquote>
<p>and yeah I was suggesting that we should express the "bounds" in terms of a bound variable, so that we can substitute different things depending on the context</p>



<a name="190983647"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190983647" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190983647">(Mar 18 2020 at 14:02)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116009">nikomatsakis</span> <a href="#narrow/stream/144729-wg-traits/topic/impl.20trait/near/190983380" title="#narrow/stream/144729-wg-traits/topic/impl.20trait/near/190983380">said</a>:</p>
<blockquote>
<p>and the "where clauses" are things that the "other code" must prove</p>
</blockquote>
<p>honestly, we could leave this for a follow-up PR too</p>



<a name="190983682"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190983682" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190983682">(Mar 18 2020 at 14:02)</a>:</h4>
<p>I would just ignore the "where clauses" part of it for the purposes of this PR, it just means that WF checking etc won't work in full generality</p>



<a name="190983695"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190983695" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190983695">(Mar 18 2020 at 14:02)</a>:</h4>
<p>we should however start making a kind of check-list of details to get back to</p>



<a name="190983862"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190983862" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190983862">(Mar 18 2020 at 14:04)</a>:</h4>
<p>Getting this PR merged would be nice, I'm going to have to rebase for the 5th time <span aria-label="slight smile" class="emoji emoji-1f642" role="img" title="slight smile">:slight_smile:</span></p>



<a name="190984039"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190984039" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190984039">(Mar 18 2020 at 14:05)</a>:</h4>
<p>yeah</p>



<a name="190984051"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190984051" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190984051">(Mar 18 2020 at 14:05)</a>:</h4>
<p>I'm <span aria-label="+1" class="emoji emoji-1f44d" role="img" title="+1">:+1:</span> on smaller PRs and checklists :)</p>



<a name="190984159"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190984159" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190984159">(Mar 18 2020 at 14:06)</a>:</h4>
<p>so you understand what I meant about using a bound variable for the hidden type, though?</p>



<a name="190984195"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190984195" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190984195">(Mar 18 2020 at 14:06)</a>:</h4>
<p>I'm going to start editing <a href="https://github.com/rust-lang/chalk/issues/335" target="_blank" title="https://github.com/rust-lang/chalk/issues/335">https://github.com/rust-lang/chalk/issues/335</a> with follow-up items</p>



<a name="190984394"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190984394" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190984394">(Mar 18 2020 at 14:08)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116009">nikomatsakis</span> <a href="#narrow/stream/144729-wg-traits/topic/impl.20trait/near/190984159" title="#narrow/stream/144729-wg-traits/topic/impl.20trait/near/190984159">said</a>:</p>
<blockquote>
<p>so you understand what I meant about using a bound variable for the hidden type, though?</p>
</blockquote>
<p>Do you mean that we should be introducing a new variable when lowering an opaque type?</p>



<a name="190984483"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190984483" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190984483">(Mar 18 2020 at 14:08)</a>:</h4>
<p>Yes</p>



<a name="190984868"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190984868" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190984868">(Mar 18 2020 at 14:11)</a>:</h4>
<p><a href="https://github.com/rust-lang/chalk/issues/335#issuecomment-600645520" target="_blank" title="https://github.com/rust-lang/chalk/issues/335#issuecomment-600645520">initial checklist</a> off the top of my head</p>



<a name="190985035"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190985035" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190985035">(Mar 18 2020 at 14:12)</a>:</h4>
<p>I'm not sure what the lowered result would look like</p>



<a name="190985071"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190985071" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190985071">(Mar 18 2020 at 14:13)</a>:</h4>
<p>let me see if I can find a decent example</p>



<a name="190985885"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190985885" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190985885">(Mar 18 2020 at 14:19)</a>:</h4>
<p><span class="user-mention" data-user-id="125131">@detrumi</span> so I think the closest example is <a href="https://github.com/rust-lang/chalk/blob/75718ac8578b884912facc192c14ccafcda6c6b5/chalk-integration/src/lowering.rs#L989-L1007" target="_blank" title="https://github.com/rust-lang/chalk/blob/75718ac8578b884912facc192c14ccafcda6c6b5/chalk-integration/src/lowering.rs#L989-L1007">the code for dyn Trait types</a></p>



<a name="190985926"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190985926" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190985926">(Mar 18 2020 at 14:19)</a>:</h4>
<p>here we are using a bound variable with the name <code>FIXME_SELF</code> that represents the "existential type" -- it's the same basic concept, except we never learn what the hidden type is :)</p>



<a name="190986172"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190986172" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190986172">(Mar 18 2020 at 14:21)</a>:</h4>
<p>I did try something along those lines <a href="https://github.com/rust-lang/chalk/pull/324/files#diff-563a3df57abd0881a3def13e3bc472c6R384" target="_blank" title="https://github.com/rust-lang/chalk/pull/324/files#diff-563a3df57abd0881a3def13e3bc472c6R384">here</a></p>



<a name="190986349"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190986349" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190986349">(Mar 18 2020 at 14:22)</a>:</h4>
<p>yeah but</p>



<a name="190986370"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190986370" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190986370">(Mar 18 2020 at 14:22)</a>:</h4>
<p>what that does is</p>



<a name="190986384"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190986384" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190986384">(Mar 18 2020 at 14:22)</a>:</h4>
<p>if you have generics like <code>type Foo&lt;T&gt;</code>, that brings <code>T</code> into scope --</p>



<a name="190986398"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190986398" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190986398">(Mar 18 2020 at 14:22)</a>:</h4>
<p>it also only brings <code>T</code> into scope during the closure</p>



<a name="190986405"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190986405" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190986405">(Mar 18 2020 at 14:22)</a>:</h4>
<p>so when lowering the "opaque type"</p>



<a name="190986625"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190986625" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190986625">(Mar 18 2020 at 14:24)</a>:</h4>
<p>Ah</p>



<a name="190986700"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190986700" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190986700">(Mar 18 2020 at 14:25)</a>:</h4>
<p>I see, that was forced by how the types were structured</p>



<a name="190986865"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190986865" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190986865">(Mar 18 2020 at 14:26)</a>:</h4>
<p>So by moving the hidden type inside the binders, we can also lower that inside the closure</p>



<a name="190987024"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190987024" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190987024">(Mar 18 2020 at 14:27)</a>:</h4>
<p>This is starting to make sense now, the way it needed multiple <code>empty_env</code> instances was weird anyways</p>



<a name="190987062"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190987062" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190987062">(Mar 18 2020 at 14:27)</a>:</h4>
<p>right but also</p>



<a name="190987095"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190987095" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190987095">(Mar 18 2020 at 14:28)</a>:</h4>
<p>well so we also want to lower whatever other things have those generics in scope w/in that same closure</p>



<a name="190987110"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190987110" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190987110">(Mar 18 2020 at 14:28)</a>:</h4>
<p>notably the bounds</p>



<a name="190987178"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190987178" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190987178">(Mar 18 2020 at 14:28)</a>:</h4>
<p>except if we want the bounds to <em>also</em> have the "hidden type" in scope</p>



<a name="190987395"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190987395" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190987395">(Mar 18 2020 at 14:29)</a>:</h4>
<p>I'm not following</p>



<a name="190987599"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190987599" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190987599">(Mar 18 2020 at 14:30)</a>:</h4>
<p>What do you mean with that last  sentence?</p>



<a name="190987697"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190987697" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190987697">(Mar 18 2020 at 14:31)</a>:</h4>
<p>sorry I got distracted before I finished</p>



<a name="190987702"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190987702" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190987702">(Mar 18 2020 at 14:31)</a>:</h4>
<p>what I meant was</p>



<a name="190987707"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190987707" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190987707">(Mar 18 2020 at 14:31)</a>:</h4>
<p>Ah, so you mean that the bounds should be able to reference the hidden type</p>



<a name="190987748"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190987748" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190987748">(Mar 18 2020 at 14:31)</a>:</h4>
<p>right, so you probably want something like</p>



<a name="190987969"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190987969" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190987969">(Mar 18 2020 at 14:33)</a>:</h4>
<div class="codehilite"><pre><span></span><span class="n">empty_env</span><span class="p">.</span><span class="n">in_binders</span><span class="p">(</span><span class="n">parameter_kinds</span><span class="p">,</span><span class="w"> </span><span class="o">|</span><span class="n">env</span><span class="o">|</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="c1">// bring the type parameters into scope</span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">hidden_ty</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="cm">/* lower hidden ty, as today */</span><span class="p">;</span><span class="w"></span>

<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">hidden_ty_bounds</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">env</span><span class="p">.</span><span class="n">in_binders</span><span class="p">(</span><span class="w"></span>
<span class="w">        </span><span class="nb">Some</span><span class="p">(</span><span class="n">chalk_ir</span>::<span class="n">ParameterKind</span>::<span class="n">Ty</span><span class="p">(</span><span class="n">intern</span><span class="p">(</span><span class="n">FIXME_SELF</span><span class="p">))),</span><span class="w"></span>
<span class="w">        </span><span class="o">|</span><span class="n">env1</span><span class="o">|</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="c1">// bring hidden type into scope</span>
<span class="w">           </span><span class="cm">/* lower bounds, using `into_where_clauses` to supply the `Self` type as the innermos bound variable */</span><span class="w"></span>
<span class="w">        </span><span class="p">}</span><span class="w"></span>
<span class="w">    </span><span class="p">);</span><span class="w"></span>

<span class="w">    </span><span class="n">ImplTraitDatumBound</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="n">hidden_ty</span><span class="p">,</span><span class="w"> </span><span class="n">hidden_ty_bounds</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
<span class="p">})</span><span class="w"></span>
</pre></div>



<a name="190988245"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190988245" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190988245">(Mar 18 2020 at 14:34)</a>:</h4>
<p>Why the FIXME_SELF?</p>



<a name="190988428"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190988428" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190988428">(Mar 18 2020 at 14:35)</a>:</h4>
<p>like, why introduce another parameter there, or why use this <code>FIXME_SELF</code> constant?</p>



<a name="190988433"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190988433" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190988433">(Mar 18 2020 at 14:35)</a>:</h4>
<p>that's the name of the parameter</p>



<a name="190988465"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190988465" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190988465">(Mar 18 2020 at 14:36)</a>:</h4>
<p>but it represents the "hidden Self type"</p>



<a name="190988547"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190988547" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190988547">(Mar 18 2020 at 14:36)</a>:</h4>
<p>i.e., if the bounds are <code>impl Foo</code>, then you have <code>$H: Foo</code>, so the hidden type <code>$H</code> is the "Self" parameter of the where clause</p>



<a name="190988598"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190988598" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190988598">(Mar 18 2020 at 14:36)</a>:</h4>
<p>In my mind we had the placeholders for that already</p>



<a name="190988616"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190988616" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190988616">(Mar 18 2020 at 14:36)</a>:</h4>
<p>Maybe I'm mixing things up though</p>



<a name="190988750"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190988750" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190988750">(Mar 18 2020 at 14:38)</a>:</h4>
<p>well</p>



<a name="190988920"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190988920" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190988920">(Mar 18 2020 at 14:38)</a>:</h4>
<p>not sure which placeholder you mean</p>



<a name="190988939"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190988939" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190988939">(Mar 18 2020 at 14:39)</a>:</h4>
<p>do you mean in the first call to <code>in_binders</code>?</p>



<a name="190989238"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190989238" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190989238">(Mar 18 2020 at 14:41)</a>:</h4>
<p>I meant the ImplTraitId placeholders (<code>!T</code>)</p>



<a name="190989274"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190989274" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190989274">(Mar 18 2020 at 14:41)</a>:</h4>
<p>Ah so</p>



<a name="190989292"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190989292" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190989292">(Mar 18 2020 at 14:41)</a>:</h4>
<p>Those represent something different</p>



<a name="190989577"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190989577" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190989577">(Mar 18 2020 at 14:43)</a>:</h4>
<p>the main difference is</p>



<a name="190989604"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190989604" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190989604">(Mar 18 2020 at 14:43)</a>:</h4>
<p>at least in the code the way it is now</p>



<a name="190989630"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190989630" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190989630">(Mar 18 2020 at 14:43)</a>:</h4>
<p>you can't "substitute" for a placeholder (i.e., replace it with something else)</p>



<a name="190989826"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190989826" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190989826">(Mar 18 2020 at 14:44)</a>:</h4>
<p>You mean that you can't substitute the placeholder in <code>in_binders</code>, right?</p>



<a name="190989860"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190989860" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190989860">(Mar 18 2020 at 14:44)</a>:</h4>
<p>Because <code>ImplTraitTy</code> does have a substitution field</p>



<a name="190989867"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190989867" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190989867">(Mar 18 2020 at 14:44)</a>:</h4>
<p>in other words, by adding a binder, we've kind of made the "bounds" be something we can apply to <em>either</em> the hidden type (when it is known) <em>or</em> to the placeholder or other things</p>



<a name="190989899"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190989899" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190989899">(Mar 18 2020 at 14:45)</a>:</h4>
<p><span class="user-mention silent" data-user-id="125131">detrumi</span> <a href="#narrow/stream/144729-wg-traits/topic/impl.20trait/near/190989826" title="#narrow/stream/144729-wg-traits/topic/impl.20trait/near/190989826">said</a>:</p>
<blockquote>
<p>You mean that you can't substitute the placeholder in <code>in_binders</code>, right?</p>
</blockquote>
<p>no</p>



<a name="190989935"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190989935" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190989935">(Mar 18 2020 at 14:45)</a>:</h4>
<p>so, <code>in_binders</code> creates a <code>Binders&lt;T&gt;</code> value which introduces various bound variables</p>



<a name="190989956"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190989956" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190989956">(Mar 18 2020 at 14:45)</a>:</h4>
<p>that may be referenced within the <code>T</code> term that is contained within</p>



<a name="190989975"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190989975" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190989975">(Mar 18 2020 at 14:45)</a>:</h4>
<p>but then <em>other code</em> can substitute values for those bound variables</p>



<a name="190990024"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190990024" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190990024">(Mar 18 2020 at 14:46)</a>:</h4>
<p>that is, <code>in_binders</code> doesn't itself do any substitution</p>



<a name="190990123"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190990123" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190990123">(Mar 18 2020 at 14:46)</a>:</h4>
<p>Ah, so you meant the opposite, in that we don't need the substitution here</p>



<a name="190990167"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190990167" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190990167">(Mar 18 2020 at 14:46)</a>:</h4>
<p>yeah but also</p>



<a name="190990173"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190990173" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190990173">(Mar 18 2020 at 14:46)</a>:</h4>
<p>the code the way it is written</p>



<a name="190990179"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190990179" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190990179">(Mar 18 2020 at 14:47)</a>:</h4>
<p>does</p>



<a name="190990209"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190990209" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190990209">(Mar 18 2020 at 14:47)</a>:</h4>
<p><code>qil.into_where_clauses(chalk_ir::TyData::BoundVar(0))</code> --</p>



<a name="190990216"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190990216" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190990216">(Mar 18 2020 at 14:47)</a>:</h4>
<p>i.e., it is saying</p>



<a name="190990239"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190990239" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190990239">(Mar 18 2020 at 14:47)</a>:</h4>
<p>convert the bounds like <code>Debug</code> into a where clause like <code>^0: Debug</code></p>



<a name="190990261"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190990261" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190990261">(Mar 18 2020 at 14:47)</a>:</h4>
<p>i.e., with the self type being the innermost bound variable</p>



<a name="190990271"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190990271" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190990271">(Mar 18 2020 at 14:47)</a>:</h4>
<p>that is actually correct <em>except</em></p>



<a name="190990291"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190990291" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190990291">(Mar 18 2020 at 14:47)</a>:</h4>
<p>we are doing that in the <code>empty_env</code></p>



<a name="190990298"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190990298" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190990298">(Mar 18 2020 at 14:47)</a>:</h4>
<p>i.e., there are no bound variables "in scope"</p>



<a name="190990388"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190990388" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190990388">(Mar 18 2020 at 14:48)</a>:</h4>
<p>and we don't store the resulting <code>QuantifiedWhereClause</code> values in a <code>Binders&lt;QuantifiedWhereClause&gt;</code></p>



<a name="190990404"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190990404" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190990404">(Mar 18 2020 at 14:48)</a>:</h4>
<p>Right, yeah I see</p>



<a name="190990408"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190990408" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190990408">(Mar 18 2020 at 14:48)</a>:</h4>
<p>so the <code>BoundVar</code> is kind of referencing "something"</p>



<a name="190990996"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190990996" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190990996">(Mar 18 2020 at 14:52)</a>:</h4>
<p>Alright. Looking at the other feedback, there's one place I was using the alias type itself instead of the placeholder, that makes sense. Hopefully fixing these also makes the tests behave more like they should</p>



<a name="190991030"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190991030" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190991030">(Mar 18 2020 at 14:52)</a>:</h4>
<p>yep</p>



<a name="190991060"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190991060" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190991060">(Mar 18 2020 at 14:52)</a>:</h4>
<p>I would expect so but maybe not :)</p>



<a name="190991080"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190991080" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190991080">(Mar 18 2020 at 14:52)</a>:</h4>
<p>let me know if you get stuck or have updated it and I can take another look</p>



<a name="190991103"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190991103" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190991103">(Mar 18 2020 at 14:53)</a>:</h4>
<p><span aria-label="+1" class="emoji emoji-1f44d" role="img" title="+1">:+1:</span></p>



<a name="190991466"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190991466" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190991466">(Mar 18 2020 at 14:55)</a>:</h4>
<p>You also mentioned the match in aggregate_tys that probably wasn't live, should we replace that with <code>unreachable!()</code> then to make sure?</p>



<a name="190991730"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/190991730" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#190991730">(Mar 18 2020 at 14:57)</a>:</h4>
<p>I also noticed that some of them might not get reached, because we don't use alias types in answers (/goals?)</p>



<a name="192667016"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/192667016" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#192667016">(Apr 02 2020 at 13:46)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> I've resolved your comments, and updated the test. It's failing now because it's not finding a solution for <code>T: Trait</code> for a <code>opaque type T: Trait = Ty;</code>, which it should</p>



<a name="192668172"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/192668172" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#192668172">(Apr 02 2020 at 13:55)</a>:</h4>
<p>Hopefully it's just wrong clauses being generated in <code>to_program_clauses</code>, otherwise I'd like to land the PR and iterate in smaller PRs</p>



<a name="192836780"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/192836780" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#192836780">(Apr 03 2020 at 17:17)</a>:</h4>
<p><span class="user-mention" data-user-id="125131">@detrumi</span> great! I'll take a look</p>



<a name="192946504"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/192946504" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#192946504">(Apr 05 2020 at 07:36)</a>:</h4>
<p>Ah, turns out I was creating <code>Implemented(HiddenTy: Bound)</code> clauses directly, instead of <code>(Implemented(!T: Bound)</code></p>



<a name="192946687"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/192946687" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#192946687">(Apr 05 2020 at 07:40)</a>:</h4>
<p>Hmm, so maybe the lowering should use <code>TypeName::OpaqueType</code> for the <code>self_ty</code> in <code>into_where_clauses</code>?</p>



<a name="192963906"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/192963906" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#192963906">(Apr 05 2020 at 15:14)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116009">nikomatsakis</span> <a href="#narrow/stream/144729-wg-traits/topic/impl.20trait/near/190987969" title="#narrow/stream/144729-wg-traits/topic/impl.20trait/near/190987969">said</a>:</p>
<blockquote>
<div class="codehilite"><pre><span></span><span class="n">empty_env</span><span class="p">.</span><span class="n">in_binders</span><span class="p">(</span><span class="n">parameter_kinds</span><span class="p">,</span><span class="w"> </span><span class="o">|</span><span class="n">env</span><span class="o">|</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="c1">// bring the type parameters into scope</span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">hidden_ty</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="cm">/* lower hidden ty, as today */</span><span class="p">;</span><span class="w"></span>

<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">hidden_ty_bounds</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">env</span><span class="p">.</span><span class="n">in_binders</span><span class="p">(</span><span class="w"></span>
<span class="w">        </span><span class="nb">Some</span><span class="p">(</span><span class="n">chalk_ir</span>::<span class="n">ParameterKind</span>::<span class="n">Ty</span><span class="p">(</span><span class="n">intern</span><span class="p">(</span><span class="n">FIXME_SELF</span><span class="p">))),</span><span class="w"></span>
<span class="w">        </span><span class="o">|</span><span class="n">env1</span><span class="o">|</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="c1">// bring hidden type into scope</span>
<span class="w">           </span><span class="cm">/* lower bounds, using `into_where_clauses` to supply the `Self` type as the innermos bound variable */</span><span class="w"></span>
<span class="w">        </span><span class="p">}</span><span class="w"></span>
<span class="w">    </span><span class="p">);</span><span class="w"></span>

<span class="w">    </span><span class="n">ImplTraitDatumBound</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="n">hidden_ty</span><span class="p">,</span><span class="w"> </span><span class="n">hidden_ty_bounds</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
<span class="p">})</span><span class="w"></span>
</pre></div>


</blockquote>
<p>Returning to this suggestion, I don't have this quite right yet. <code>hidden_ty_bounds</code> in the example above would be a <code>Binders&lt;Vec&lt;Binders&lt;_&gt;&gt;&gt;</code> (the inner binders coming from lowering the bounds, and the outer binders from the second <code>in_binders</code>). The DatumBound.hidden_ty_bounds field doesn't expect binders, so I don't see a way to do this using <code>in_binders</code></p>



<a name="192966377"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/192966377" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#192966377">(Apr 05 2020 at 16:16)</a>:</h4>
<p>More specifically, I currently have this, but the <code>bounds: bounds.value</code> part just seems wrong:</p>
<div class="codehilite"><pre><span></span>let binders = empty_env.in_binders(parameter_kinds, |env| {
    let hidden_ty = opaque_ty.ty.lower(&amp;env)?;

    let bounds: chalk_ir::Binders&lt;Vec&lt;chalk_ir::Binders&lt;_&gt;&gt;&gt; = env
        .in_binders(
            Some(chalk_ir::ParameterKind::Ty(intern(FIXME_SELF))),
            |env1| {
                let interner = env1.interner();
                Ok(opaque_ty
                    .bounds
                    .lower(&amp;env1)?
                    .iter()
                    .flat_map(|qil| {
                        qil.into_where_clauses(
                            interner,
                            chalk_ir::TyData::BoundVar(BoundVar::new(
                                DebruijnIndex::INNERMOST,
                                0,
                            ))
                            .intern(interner),
                        )
                    })
                    .collect())
            },
        )?;

    Ok(OpaqueTyDatumBound {
        hidden_ty,
        bounds: bounds.value,
    })
})?;
</pre></div>



<a name="193067163"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/193067163" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#193067163">(Apr 06 2020 at 16:31)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116009">nikomatsakis</span> <a href="#narrow/stream/144729-wg-traits/topic/impl.20trait/near/192836780" title="#narrow/stream/144729-wg-traits/topic/impl.20trait/near/192836780">said</a>:</p>
<blockquote>
<p><span class="user-mention silent" data-user-id="125131">detrumi</span> great! I'll take a look</p>
</blockquote>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> Ping! Do you have a suggestion for how to avoid the <code>Binders&lt;Vec&lt;Binders&lt;_&gt;&gt;&gt;</code> problem I described above?</p>



<a name="193088660"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/193088660" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#193088660">(Apr 06 2020 at 19:21)</a>:</h4>
<p><span class="user-mention" data-user-id="125131">@detrumi</span> sorry, didn't have time to take a look, but I can look now</p>



<a name="193089009"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/193089009" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#193089009">(Apr 06 2020 at 19:24)</a>:</h4>
<p><span class="user-mention" data-user-id="125131">@detrumi</span> I think I imagined you would change <code>OpaqueTyBound</code> to</p>
<div class="codehilite"><pre><span></span><span class="k">pub</span><span class="w"> </span><span class="k">struct</span> <span class="nc">OpaqueTyBound</span><span class="o">&lt;</span><span class="n">I</span>: <span class="nc">Interner</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="sd">/// The value for the &quot;hidden type&quot; for `opaque type Foo = ...`</span>
<span class="w">    </span><span class="k">pub</span><span class="w"> </span><span class="n">hidden_ty</span>: <span class="nc">Ty</span><span class="o">&lt;</span><span class="n">I</span><span class="o">&gt;</span><span class="p">,</span><span class="w"></span>

<span class="w">    </span><span class="sd">/// Trait bounds for the opaque type.</span>
<span class="w">    </span><span class="k">pub</span><span class="w"> </span><span class="n">bounds</span>: <span class="nc">Binder</span><span class="o">&lt;</span><span class="nb">Vec</span><span class="o">&lt;</span><span class="n">QuantifiedWhereClause</span><span class="o">&lt;</span><span class="n">I</span><span class="o">&gt;&gt;&gt;</span><span class="p">,</span><span class="w">   </span><span class="c1">// &lt;-- i.e., add a binder here!</span>
<span class="p">}</span><span class="w"></span>
</pre></div>



<a name="193089054"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/193089054" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#193089054">(Apr 06 2020 at 19:24)</a>:</h4>
<p>this will require you to instantiate that binder at various points</p>



<a name="193095170"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/193095170" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#193095170">(Apr 06 2020 at 20:14)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> Hmm, does that replace the binders on <code>OpaqueTyDatum.bound</code>, or is this an extra level of binders?</p>



<a name="193095186"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/193095186" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#193095186">(Apr 06 2020 at 20:14)</a>:</h4>
<p>extra level</p>



<a name="193095200"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/193095200" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#193095200">(Apr 06 2020 at 20:14)</a>:</h4>
<p>for the same reason that we have two calls to <code>in_binders</code>, basically</p>



<a name="193095415"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/193095415" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#193095415">(Apr 06 2020 at 20:16)</a>:</h4>
<p>Ah. I probably shouldn't be using <code>bound.value</code> directly in <code>ToProgramClauses</code> then, because that throws away the binders</p>



<a name="193096648"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/193096648" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#193096648">(Apr 06 2020 at 20:24)</a>:</h4>
<p>right</p>



<a name="193096672"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/193096672" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#193096672">(Apr 06 2020 at 20:24)</a>:</h4>
<p>definitely if you find you are throwing away binders, something is kind of doing wrong</p>



<a name="193096905"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/193096905" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#193096905">(Apr 06 2020 at 20:26)</a>:</h4>
<p>Heh, guess I need to think of some other names than <code>bound</code>:</p>
<div class="codehilite"><pre><span></span>for bound in &amp;opaque_ty_bound.bounds {
    // Implemented(!T&lt;..&gt;: Bound).
    builder.push_binders(&amp;bound, |builder, bound| {
        builder.push_binders(&amp;bound, |builder, bound| {
            builder.push_fact(bound.into_well_formed_goal(interner));
        });
    });
}
</pre></div>



<a name="193097262"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/193097262" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#193097262">(Apr 06 2020 at 20:29)</a>:</h4>
<p>heh, orthogonal from your PR, but I also don't really like the <code>FooBound</code> naming convention, and particularly don't liek that I called many of the fields <code>binders</code></p>



<a name="193097279"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/193097279" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#193097279">(Apr 06 2020 at 20:29)</a>:</h4>
<p>the code gets pretty hard to read</p>



<a name="193097290"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/193097290" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#193097290">(Apr 06 2020 at 20:29)</a>:</h4>
<p>Still didn't get the <code>T: Clone</code> goal to be proven for <code>opaque type T: Clone = Ty;</code>, sadly</p>



<a name="193097428"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/193097428" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#193097428">(Apr 06 2020 at 20:30)</a>:</h4>
<p>Agreed, naming improvements would be good to do afterwards</p>



<a name="193097944"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/193097944" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#193097944">(Apr 06 2020 at 20:34)</a>:</h4>
<p>OK, I didn't do a detailed review, I can try to do that later</p>



<a name="193098277"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/193098277" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#193098277">(Apr 06 2020 at 20:37)</a>:</h4>
<p>Yeah, hopefully we can get this merged then. I'll just rebase first</p>



<a name="193099309"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/193099309" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#193099309">(Apr 06 2020 at 20:45)</a>:</h4>
<p>Rebased</p>



<a name="193314850"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/193314850" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#193314850">(Apr 08 2020 at 12:56)</a>:</h4>
<p>That's strange, <code>OpaqueTyDatum.to_program_clauses</code> isn't even being called for the failing test...</p>



<a name="193876379"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/193876379" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#193876379">(Apr 14 2020 at 10:19)</a>:</h4>
<p>Hey <span class="user-mention" data-user-id="125131">@detrumi</span> are you around by any chance?</p>



<a name="193877244"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/193877244" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#193877244">(Apr 14 2020 at 10:28)</a>:</h4>
<p>OK, <a href="https://github.com/rust-lang/chalk/pull/324#pullrequestreview-392782721" title="https://github.com/rust-lang/chalk/pull/324#pullrequestreview-392782721">I left a review here</a> and the most notable comments are <a href="https://github.com/rust-lang/chalk/pull/324#discussion_r408027278" title="https://github.com/rust-lang/chalk/pull/324#discussion_r408027278">around this point</a>. I suspect the changes I suggest will fix the test. :)</p>



<a name="193882107"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/193882107" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#193882107">(Apr 14 2020 at 11:20)</a>:</h4>
<p>Moving the substitution and such into <code>push_binders</code> didn't fix the test, but I haven't looked at the other changes yet</p>



<a name="193882862"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/193882862" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#193882862">(Apr 14 2020 at 11:28)</a>:</h4>
<p><code>bound.substitute(interner, &amp;[alias_placeholder_ty])</code> doesn't work because <code>alias_placeholder_ty</code> is a <code>Ty&lt;I&gt;</code>, which doesn't implement <code>AsParameters&lt;I&gt;</code></p>



<a name="193883123"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/193883123" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#193883123">(Apr 14 2020 at 11:30)</a>:</h4>
<p>Should be <code>&amp;Substitution::from1(interner, alias_placeholder_ty.clone())</code>, I think</p>



<a name="193887394"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/193887394" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#193887394">(Apr 14 2020 at 12:16)</a>:</h4>
<p>sure, that works. We could probably implement <code>AsParameters&lt;I&gt;</code> for <code>[Ty&lt;I&gt;]</code> as well but...</p>



<a name="193887419"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/193887419" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#193887419">(Apr 14 2020 at 12:17)</a>:</h4>
<p>(or even for <code>Ty&lt;I&gt;</code> as a singleton list)</p>



<a name="193887457"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/193887457" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#193887457">(Apr 14 2020 at 12:17)</a>:</h4>
<p><span class="user-mention" data-user-id="125131">@detrumi</span> push changes as you go and I can run tests locally</p>



<a name="193887483"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/193887483" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#193887483">(Apr 14 2020 at 12:17)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> pushed already</p>



<a name="193889837"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/193889837" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#193889837">(Apr 14 2020 at 12:38)</a>:</h4>
<p>(don't have time rn to look into it further, will look at it later today)</p>



<a name="193891767"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/193891767" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#193891767">(Apr 14 2020 at 12:55)</a>:</h4>
<p><span class="user-mention" data-user-id="125131">@detrumi</span> I think I see the problem.</p>



<a name="193891781"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/193891781" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#193891781">(Apr 14 2020 at 12:55)</a>:</h4>
<p>I can leave a comment on the PR</p>



<a name="193892357"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/193892357" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#193892357">(Apr 14 2020 at 13:00)</a>:</h4>
<p><a href="https://github.com/rust-lang/chalk/pull/324#issuecomment-613428033" title="https://github.com/rust-lang/chalk/pull/324#issuecomment-613428033">done</a></p>



<a name="193898564"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/193898564" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#193898564">(Apr 14 2020 at 13:45)</a>:</h4>
<p>Good point, something like that was missing. I'm trying something like this, but it doesn't fix the test yet:</p>
<div class="codehilite"><pre><span></span>if let TyData::Apply(ApplicationTy {
                name: TypeName::OpaqueType(opaque_ty_id),
                ..
            }) = self_ty.data(interner)
            {
                db.opaque_ty_data(*opaque_ty_id).to_program_clauses(builder);
            }
</pre></div>


<p>Will look into it more (and probably add/use some helper methods as well)</p>



<a name="193932916"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/193932916" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#193932916">(Apr 14 2020 at 17:43)</a>:</h4>
<p><span class="user-mention" data-user-id="125131">@detrumi</span> can you push to your branch?</p>



<a name="193938585"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/193938585" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#193938585">(Apr 14 2020 at 18:29)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> oops, pushed now</p>



<a name="193938952"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/193938952" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#193938952">(Apr 14 2020 at 18:32)</a>:</h4>
<p>Doesn't look like that code path is being hit</p>



<a name="193946734"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/193946734" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#193946734">(Apr 14 2020 at 19:35)</a>:</h4>
<p><span class="user-mention" data-user-id="125131">@detrumi</span> hmm</p>



<a name="193946865"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/193946865" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#193946865">(Apr 14 2020 at 19:36)</a>:</h4>
<p>doing some quick debugging</p>



<a name="193946953"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/193946953" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#193946953">(Apr 14 2020 at 19:37)</a>:</h4>
<p>ok, right, so the problem is</p>



<a name="193947580"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/193947580" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#193947580">(Apr 14 2020 at 19:43)</a>:</h4>
<p>well, so let me push one relevant change</p>



<a name="193947589"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/193947589" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#193947589">(Apr 14 2020 at 19:43)</a>:</h4>
<p>I am adding the rules also if the self type is the "alias" version of the opaque type</p>



<a name="193947616"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/193947616" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#193947616">(Apr 14 2020 at 19:43)</a>:</h4>
<p>but that's not quite enough to see the problem, I suspect that the rules are being removed</p>



<a name="193947715"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/193947715" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#193947715">(Apr 14 2020 at 19:44)</a>:</h4>
<p>oh, hmm, that's not quite right</p>



<a name="193947766"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/193947766" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#193947766">(Apr 14 2020 at 19:45)</a>:</h4>
<p>ah, I see</p>



<a name="193947906"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/193947906" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#193947906">(Apr 14 2020 at 19:46)</a>:</h4>
<p><span class="user-mention" data-user-id="125131">@detrumi</span> so this was the diff</p>
<div class="codehilite"><pre><span></span>modified   chalk-solve/src/clauses/program_clauses.rs
<span class="gu">@@ -175,7 +175,7 @@ impl&lt;I: Interner&gt; ToProgramClauses&lt;I&gt; for OpaqueTyDatum&lt;I&gt; {</span>
                     &amp;Substitution::from1(interner, alias_placeholder_ty.clone()),
                 );
                 builder.push_binders(&amp;bound_with_placeholder_ty, |builder, bound| {
<span class="gd">-                    builder.push_fact(bound.into_well_formed_goal(interner));</span>
<span class="gi">+                    builder.push_fact(bound);</span>
                 });
             }
</pre></div>



<a name="193947932"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/193947932" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#193947932">(Apr 14 2020 at 19:46)</a>:</h4>
<p>given a type like <code>type Foo = impl Debug</code>, you were generating <code>WellFormed(!Foo: Debug)</code>, and not <code>Implemented(!Foo: Debug)</code></p>



<a name="193947953"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/193947953" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#193947953">(Apr 14 2020 at 19:46)</a>:</h4>
<p>with that change, the test passes</p>



<a name="193947981"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/193947981" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#193947981">(Apr 14 2020 at 19:47)</a>:</h4>
<p>Woah, <span aria-label="tada" class="emoji emoji-1f389" role="img" title="tada">:tada:</span></p>



<a name="193948214"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/193948214" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#193948214">(Apr 14 2020 at 19:49)</a>:</h4>
<p>Good catch, yeah that doesn't fit there</p>



<a name="193948254"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/193948254" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#193948254">(Apr 14 2020 at 19:49)</a>:</h4>
<p>just for reference,</p>



<a name="193948258"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/193948258" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#193948258">(Apr 14 2020 at 19:49)</a>:</h4>
<p>the way I debugged this,</p>



<a name="193948274"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/193948274" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#193948274">(Apr 14 2020 at 19:49)</a>:</h4>
<p>was basically to look at what program clauses were being generated for the goal</p>



<a name="193948326"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/193948326" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#193948326">(Apr 14 2020 at 19:50)</a>:</h4>
<p>I was looking for one that looked like <code>Implemented(!T: Debug)</code> and I kept not seeing it :P</p>



<a name="193948391"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/193948391" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#193948391">(Apr 14 2020 at 19:50)</a>:</h4>
<p>also, the debug output for these things is really painful, it'd be nice to see <code>!Foo</code> or something and not the current output...</p>



<a name="193948435"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/193948435" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#193948435">(Apr 14 2020 at 19:51)</a>:</h4>
<p>Yeah, pushed a fix for that just now</p>



<a name="193948470"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/193948470" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#193948470">(Apr 14 2020 at 19:51)</a>:</h4>
<p>Wasn't looking at the CHALK_DEBUG=1 output, which I should've been doing</p>



<a name="193948714"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/193948714" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#193948714">(Apr 14 2020 at 19:53)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> Wait, did you have more changes? Because just that change doesn't fix the <code>opaque_bounds</code> test</p>



<a name="193948902"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/193948902" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#193948902">(Apr 14 2020 at 19:54)</a>:</h4>
<p>oh</p>



<a name="193948903"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/193948903" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#193948903">(Apr 14 2020 at 19:54)</a>:</h4>
<p>wait</p>



<a name="193948948"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/193948948" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#193948948">(Apr 14 2020 at 19:55)</a>:</h4>
<p>pushed</p>



<a name="193949145"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/193949145" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#193949145">(Apr 14 2020 at 19:56)</a>:</h4>
<p>Ah, so a match for AliasTy::Opaque was missing in program_clauses_that_could_match. <span aria-label="+1" class="emoji emoji-1f44d" role="img" title="+1">:+1:</span></p>



<a name="193949265"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/193949265" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#193949265">(Apr 14 2020 at 19:57)</a>:</h4>
<p>Yeah, so the reason that comes about</p>



<a name="193949294"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/193949294" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#193949294">(Apr 14 2020 at 19:57)</a>:</h4>
<p>is because we start out with the goal using the <em>unnormalized</em> type</p>



<a name="193949312"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/193949312" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#193949312">(Apr 14 2020 at 19:57)</a>:</h4>
<p>actually if we adopt the "sem vs syntatic equality" thing</p>



<a name="193949362"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/193949362" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#193949362">(Apr 14 2020 at 19:58)</a>:</h4>
<p>that would no longer be true...</p>



<a name="193949379"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/193949379" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#193949379">(Apr 14 2020 at 19:58)</a>:</h4>
<p>...but for now it's true</p>



<a name="193949400"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/193949400" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#193949400">(Apr 14 2020 at 19:58)</a>:</h4>
<p>I was wondering, side note, whether those goals should <em>actually</em> be FromEnv goals</p>



<a name="193949439"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/193949439" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#193949439">(Apr 14 2020 at 19:58)</a>:</h4>
<p>but I think it's fine as is, that kind of relates to implied bounds</p>



<a name="193949455"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/193949455" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#193949455">(Apr 14 2020 at 19:58)</a>:</h4>
<p>we might change it later, easy enough to do</p>



<a name="193949479"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/193949479" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#193949479">(Apr 14 2020 at 19:59)</a>:</h4>
<p>still, I <em>think</em> the corresponding stuff for associated types is <code>FromEnv</code>? have to compare</p>



<a name="193949511"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/193949511" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#193949511">(Apr 14 2020 at 19:59)</a>:</h4>
<p>What would it be instead of <code>FromEnv</code>?</p>



<a name="193949517"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/193949517" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#193949517">(Apr 14 2020 at 19:59)</a>:</h4>
<p>at minimum I was surprised that I didn't see similar rules for "unnormalized associated types", which made me think that it's probably in the <code>FromEnv</code> section</p>



<a name="193949537"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/193949537" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#193949537">(Apr 14 2020 at 19:59)</a>:</h4>
<p>what I mean is:</p>



<a name="193949548"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/193949548" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#193949548">(Apr 14 2020 at 19:59)</a>:</h4>
<p>we are generating clauses like <code>Implemented(!Foo: Debug)</code></p>



<a name="193949567"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/193949567" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#193949567">(Apr 14 2020 at 19:59)</a>:</h4>
<p>but maybe we should be generating <code>FromEnv(!Foo: Debug)</code></p>



<a name="193949585"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/193949585" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#193949585">(Apr 14 2020 at 19:59)</a>:</h4>
<p>which would also work, because <code>Implemented(T: Debug) :- FromEnv(T: Debug)</code></p>



<a name="193949630"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/193949630" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#193949630">(Apr 14 2020 at 20:00)</a>:</h4>
<p>anyway we'll get into all that in next week's design meeting I suppose ;)</p>



<a name="193949650"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/193949650" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#193949650">(Apr 14 2020 at 20:00)</a>:</h4>
<p>Ah, yeah, that'd make more sense</p>



<a name="194321818"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/194321818" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#194321818">(Apr 16 2020 at 15:26)</a>:</h4>
<p><span class="user-mention" data-user-id="125131">@detrumi</span> merged!</p>



<a name="194669253"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/194669253" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Areredify <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#194669253">(Apr 20 2020 at 12:46)</a>:</h4>
<p><code>DynTy</code> documentation states that it could be an <code>impl Trait</code>, is this info outdated and opaque types live either in <code>AliasTy</code> or <code>ApplicationTy</code>?</p>



<a name="194681164"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/194681164" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#194681164">(Apr 20 2020 at 14:20)</a>:</h4>
<p>Yes, <code>DynTy</code> is now only used for <code>dyn Trait</code>, and the documentation is outdated there</p>



<a name="194681451"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/194681451" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Areredify <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#194681451">(Apr 20 2020 at 14:22)</a>:</h4>
<p>Ok, I'll fix it in a relevant pr then</p>



<a name="194681698"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/194681698" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#194681698">(Apr 20 2020 at 14:24)</a>:</h4>
<p>Thanks! Yeah, I still need to get around to documenting opaque types, but there's bound to be other places that have outdated info</p>



<a name="194708298"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/194708298" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#194708298">(Apr 20 2020 at 17:34)</a>:</h4>
<p>Figuring out how all the rules work is kinda tricky. I'm trying to get generic opaque types working, using something like this:</p>
<div class="codehilite"><pre><span></span>program {
    ...
    opaque type Foo&lt;X&gt;: Iterator&lt;Item = X&gt; = Vec&lt;X&gt;
} goal {
    Foo&lt;u32&gt;: Iterator&lt;Item = u32&gt;
}
</pre></div>



<a name="194708338"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/194708338" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#194708338">(Apr 20 2020 at 17:34)</a>:</h4>
<p>It then gets stuck on this goal, with an empty environment:</p>
<div class="codehilite"><pre><span></span>all(
    AliasEq(&lt;!Foo&lt;u32&gt; as Iterator&gt;::Item = u32),
    Implemented(!Foo&lt;u32&gt;: Iterator)
)
</pre></div>



<a name="194708521"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/194708521" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#194708521">(Apr 20 2020 at 17:36)</a>:</h4>
<p>Ah, maybe I should just look at projections, since those normalize clauses are almost the same</p>



<a name="194708646"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/194708646" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#194708646">(Apr 20 2020 at 17:37)</a>:</h4>
<p>Yeah, those have <code>Env([for&lt;&gt; FromEnv(!1_0: Iterator)])</code> instead of <code>Env([])</code>, so I'm missing something</p>



<a name="194710413"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/194710413" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#194710413">(Apr 20 2020 at 17:52)</a>:</h4>
<p>Ooh, that's from the where_clauses/binders. Those layers of binders still confuse me</p>



<a name="195377732"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/195377732" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#195377732">(Apr 27 2020 at 06:38)</a>:</h4>
<p>Hmm, that's still not working. Something is still missing before this test works, not sure if it's the WF rules or implied bounds</p>



<a name="195481830"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/195481830" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#195481830">(Apr 27 2020 at 22:14)</a>:</h4>
<p>Hey <span class="user-mention" data-user-id="125131">@detrumi</span> -- I didnt' quite get to your PR, but are your questions in there?</p>



<a name="195481854"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/195481854" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#195481854">(Apr 27 2020 at 22:15)</a>:</h4>
<p>i.e., if I pull from your branch, can I reproduce the problems?</p>



<a name="195523665"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/195523665" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#195523665">(Apr 28 2020 at 06:37)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> Yes, I've pushed the failing test now. And I guess the main question is whether generics with opaque types should work like this, or whether implied bounds interactions need to be handled first</p>



<a name="195668785"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/195668785" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#195668785">(Apr 29 2020 at 07:11)</a>:</h4>
<p>Simply changing <code>Implemented</code> to <code>FromEnv</code> in the rules causes the simpler <code>opaque_bounds</code> test to fail, so either that's wrong or I'm missing a rule somewhere</p>



<a name="196244063"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/196244063" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#196244063">(May 04 2020 at 21:47)</a>:</h4>
<p>Hey <span class="user-mention" data-user-id="125131">@detrumi</span> -- how's it going here</p>



<a name="196244363"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/196244363" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#196244363">(May 04 2020 at 21:51)</a>:</h4>
<p>I'm wondering if I should be giving feedback to help push this along</p>



<a name="196358717"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/196358717" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#196358717">(May 05 2020 at 19:56)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> So, I'm mostly just overwhelmed by implied bound interactions, and have a hard time debugging it. But maybe I've started with the hard part here</p>



<a name="198229257"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/198229257" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nathan Whitaker <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#198229257">(May 20 2020 at 17:14)</a>:</h4>
<p>I've been looking into opaque type generics recently (picking up where @detrumi left off) and I've figured out why the test in the draft PR fails, but I'm unsure of the best way to fix it.<br>
For context, the test case is:</p>
<div class="codehilite"><pre><span></span><code>program {
    trait Iterator { type Item; }

    struct Vec&lt;T&gt; { }
    struct Bar { }
    impl&lt;T&gt; Iterator for Vec&lt;T&gt; {
        type Item = T;
    }

    opaque type Foo&lt;X&gt;: Iterator&lt;Item = X&gt; = Vec&lt;X&gt;;
} goal {
    Foo&lt;Bar&gt;: Iterator&lt;Item = Bar&gt;
}
</code></pre></div>


<p>The problem is essentially this:</p>
<ul>
<li>We model the placeholder type <code>!Foo</code> for the opaque type as an application type (which makes sense, as we are applying a substitution to it)</li>
<li>Our goal for this test case is:</li>
</ul>
<div class="codehilite"><pre><span></span><code>all(
    AliasEq(&lt;!Foo&lt;Bar&gt; as Iterator&gt;::Item = Bar),
    Implemented(!Foo&lt;Bar&gt;: Iterator)
)
</code></pre></div>


<ul>
<li>We attempt to solve the <code>AliasEq</code> goal, which entails proving <code>Normalize(&lt;!Foo&lt;Bar&gt; as Iterator&gt;::Item -&gt; Bar)</code></li>
<li>As part of proving the <code>Normalize</code> clause, we search for implementations of <code>Iterator</code>,  and find the clause <code>Normalize(&lt;Vec&lt;?0&gt; as Iterator&gt;::Item = ?0)</code></li>
<li>We attempt to unify <code>Normalize(&lt;Vec&lt;?0&gt; as Iterator&gt;::Item = ?0</code> with <code>Normalize(&lt;!Foo&lt;Bar&gt; as Iterator&gt;::Item -&gt;Bar)</code></li>
<li>During unification, we try to unify <code>Vec</code> and <code>!Foo</code></li>
<li><code>!Foo</code> is an application type, and so is <code>Vec</code>, and unification for application types only succeeds if the type names are equivalent (which they aren't), so unification fails. </li>
<li>There are no more relevant clauses to help prove our goal, and so we fail to find a solution</li>
</ul>



<a name="198229589"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/198229589" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nathan Whitaker <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#198229589">(May 20 2020 at 17:17)</a>:</h4>
<p>My initial thoughts as to a solution are:</p>
<ul>
<li>Don't model the placeholder as in application type</li>
<li>Add a special case to unification which allows application types with an opaque type name to unify with other application types</li>
</ul>
<p>but I'd love to hear other thoughts/insight</p>



<a name="198230411"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/198230411" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#198230411">(May 20 2020 at 17:24)</a>:</h4>
<p><code>Normalize(&lt;Vec&lt;?0&gt; as Iterator&gt;::Item = ?0)</code> is not the clause from which we should prove that goal</p>



<a name="198230587"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/198230587" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#198230587">(May 20 2020 at 17:26)</a>:</h4>
<p>there should be a clause like <code>for&lt;T&gt; AliasEq(&lt;!Foo&lt;T&gt; as Iterator&gt;::Item = T)</code> because that's how the opaque type is defined</p>



<a name="198230733"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/198230733" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#198230733">(May 20 2020 at 17:27)</a>:</h4>
<p>(the <code>Vec</code> clause is only relevant for proving the well-formedness of the opaque type definition; proving things about the opaque type itself then should not require knowledge about what's behind it -- that's the whole point of opaque types)</p>



<a name="198230748"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/198230748" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#198230748">(May 20 2020 at 17:27)</a>:</h4>
<p>(except for auto traits, of course)</p>



<a name="198230947"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/198230947" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#198230947">(May 20 2020 at 17:28)</a>:</h4>
<p>i.e. I think there needs to be some logic in <code>program_clauses</code> that produces the <code>AliasEq</code> clause</p>



<a name="198234443"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/198234443" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#198234443">(May 20 2020 at 17:57)</a>:</h4>
<p>and my guess is that <a href="https://github.com/rust-lang/chalk/blob/499d49245c117ffb78109cfd3a16496b2d832866/chalk-solve/src/clauses/program_clauses.rs#L172-L178">this</a> already produces those clauses; it just doesn't get called in the right situations</p>



<a name="198254435"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/198254435" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nathan Whitaker <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#198254435">(May 20 2020 at 20:40)</a>:</h4>
<p>Ah yes that makes sense, and indeed <code>to_program_clauses</code> isn't being called for the opaque type during solving. Thanks for the help!</p>



<a name="198306883"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/198306883" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#198306883">(May 21 2020 at 10:38)</a>:</h4>
<p><span class="user-mention" data-user-id="230601">@Nathan Whitaker</span> Oh wow, great work</p>



<a name="198306927"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/198306927" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#198306927">(May 21 2020 at 10:38)</a>:</h4>
<p>I think the test should also work without the <code>impl&lt;T&gt; Iterator for Vec&lt;T&gt;</code> part, since the goal should be implied because of the bound on the opaque type</p>



<a name="198335343"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/198335343" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nathan Whitaker <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#198335343">(May 21 2020 at 15:32)</a>:</h4>
<p>Good point! Updated the test in the PR to reflect that.</p>



<a name="198354692"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/198354692" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#198354692">(May 21 2020 at 18:01)</a>:</h4>
<p>Nit: same thing in the <code>opaque_generics_simple</code> test</p>



<a name="198354946"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/198354946" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#198354946">(May 21 2020 at 18:03)</a>:</h4>
<p>Hmm actually, this might change once WF checks are implemented, so never mind</p>



<a name="198823283"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/198823283" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#198823283">(May 26 2020 at 21:21)</a>:</h4>
<p>Seems like we should discuss the usage of placeholder vs alias in impl Trait -- <span class="user-mention" data-user-id="129457">@Florian Diebold</span> brought it up and it was also relevant to the auto trait PR I just merged (perhaps hastily?)</p>



<a name="198823348"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/198823348" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#198823348">(May 26 2020 at 21:22)</a>:</h4>
<p>I think I would expect that all the program clauses we make <em>apart</em> from <code>AliasEq</code> rules use the placeholder form</p>



<a name="198823580"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/198823580" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#198823580">(May 26 2020 at 21:24)</a>:</h4>
<p>I think that makes sense, but they still need to check for both forms in the goal, right?</p>



<a name="198823615"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/198823615" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#198823615">(May 26 2020 at 21:24)</a>:</h4>
<p>the time being, I think that's right</p>



<a name="198823651"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/198823651" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#198823651">(May 26 2020 at 21:25)</a>:</h4>
<p>the "semantic-syntactic" equality would I guess change that</p>



<a name="198823708"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/198823708" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#198823708">(May 26 2020 at 21:25)</a>:</h4>
<p>and e.g. in rust-analyzer, impl trait starts off in the alias form?</p>



<a name="198823822"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/198823822" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#198823822">(May 26 2020 at 21:26)</a>:</h4>
<p>i.e. we never create placeholder types directly</p>



<a name="198824445"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/198824445" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#198824445">(May 26 2020 at 21:32)</a>:</h4>
<p>right</p>



<a name="198824467"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/198824467" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#198824467">(May 26 2020 at 21:33)</a>:</h4>
<p>the idea is that you generate what the "user types" (which is the alias form)</p>



<a name="198824474"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/198824474" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#198824474">(May 26 2020 at 21:33)</a>:</h4>
<p>and chalk figures out the rest, so to speak</p>



<a name="198828198"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/198828198" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#198828198">(May 26 2020 at 22:13)</a>:</h4>
<p>so can <a href="https://github.com/rust-lang-nursery/chalk/issues/473">chalk#473</a> be merged?</p>



<a name="198828734"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/198828734" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#198828734">(May 26 2020 at 22:20)</a>:</h4>
<p>Seems okay to me</p>



<a name="199913059"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/199913059" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#199913059">(Jun 05 2020 at 18:04)</a>:</h4>
<p>WF checks are kinda tricky, but it feels like I'm getting somewhere now.</p>



<a name="199913088"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/199913088" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#199913088">(Jun 05 2020 at 18:04)</a>:</h4>
<p>Given this opaque type:</p>
<div class="codehilite"><pre><span></span><code>opaque type Foo&lt;T&gt;: A&lt;U&gt; + B&lt;V&gt; = HiddenTy&lt;T&gt;
</code></pre></div>



<a name="199913119"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/199913119" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#199913119">(Jun 05 2020 at 18:04)</a>:</h4>
<p>I _think_ it should be something like this:</p>
<div class="codehilite"><pre><span></span><code>forall&lt;T&gt; {
    exists&lt;U, V&gt; {
        if (FromEnv(HiddenTy&lt;T&gt;: A&lt;U&gt;) &amp;&amp; FromEnv(HiddenTy&lt;T&gt;: B&lt;V&gt;)) {
            FromEnv(Foo&lt;T&gt;: A&lt;U&gt;) &amp;&amp; FromEnv(Foo&lt;T&gt;: B&lt;V&gt;)
        }
    }
}
</code></pre></div>



<a name="199913376"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/199913376" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#199913376">(Jun 05 2020 at 18:06)</a>:</h4>
<p>I've thought about creating a goal for each bound separately, but that might be problematic when there's where clauses (e.g. <code>opaque type Foo: A + B where Foo: C = HiddennType</code>)</p>



<a name="199919840"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/199919840" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#199919840">(Jun 05 2020 at 18:55)</a>:</h4>
<p>Hmm, not sure whether it's possible to get that <code>exists&lt;U, V&gt;</code> from the bounds <code>Vec&lt;QuantifiedWhereClause&lt;I&gt;&gt;</code></p>



<a name="199988888"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/199988888" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#199988888">(Jun 06 2020 at 19:10)</a>:</h4>
<p>Ah, there shouldn't even be a <code>forall&lt;T&gt;</code>, since the parameters to the opaque type should be hose of the hidden type</p>



<a name="199989011"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/impl%20trait/near/199989011" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/impl.20trait.html#199989011">(Jun 06 2020 at 19:13)</a>:</h4>
<p>Not sure if we can assume that the hidden type is an <code>ApplicationTy</code> though, since it might be an alias? (something like <code>type Foo = Bar&lt;T&gt;</code>)</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>